npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

robot-npm-dbmaster

v1.1.2-beta

Published

npm module for working with the dbMaster. Created for a private project

Downloads

1

Readme

robot-npm-dbMaster

1.1.2-beta

npm module for working with the dbMaster. Created for a private project.

new in 1.1.*

We've added the support of using in typescript projects.

install

$ npm install robot-npm-dbmaster --save

uninstall

$ npm uninstall robot-npm-dbmaster --save

usage

/*
* Import the class that is contains methods for working with dbMaster.
* */
const { CRUD } = require('robot-npm-dbmaster');

/*
* The same import, but for typescript.
*/
import { CRUD } from 'robot-npm-dbmaster';

/*
* In current example we'll use the "switch case" construction to realize optional choosing of methods.
* */

// set method that we are going to use.
const method = 'create';

// in this var we'll get te response.
let response;
// create the object crud of class CRUD.
// as an argument we put url where are located routes we are sending requests to.
const crud = new CRUD('http://localhost:3000');

// asking methods mast being in async function.
(async () => {
    switch (method) {
        case 'create':
            /*
            * we use method create to create a new object in the database table.
            * arguments:
            *   - Model - model we are working with.
            *   - inData - data of creating object.
            *
            * crud.create([Model], [inData])
            * */
            response = await crud.create('Config', {
                varName: "myIP",
                varType: "STRING",
                stringVal: "127.0.0.1",
                intVal: 0
            })
            break;

        case 'getOne':
            /*
            * we use method getOne to get one object from the database table.
            * arguments:
            *   - Model - model we are working with.
            *   - by - name of field we are finding by.
            *   - value - name of field we are finding by.
            *
            * crud.create([Model], [by], [value])
            * */
            response = await crud.getOne('Config', 'myIP', '127.0.0.1');
            break;

        case 'getAll':
            /*
            * we use method getAll to get all objects from the database table.
            * arguments:
            *   - Model - model we are working with.
            *
            * crud.create([Model])
            * */
            response = await crud.getAll('Config');
            break;

        case 'update':
            /*
            * we use method update to update an object in the database table.
            * arguments:
            *   - Model - model we are working with.
            *   - by - object that database will find object to update by.
            *   - inData - object that will be put on the place of the old object.
            *
            * crud.create([Model], [by], [inData])
            * */
            response = await crud.update(
                'Config',
                {
                    myIP: "127.0.0.1"
                },
                {
                    varName: "myIP",
                    varType: "STRING",
                    stringVal: "127.0.0.2",
                    intVal: 0
                }
            )
            break;
        case 'remove':
            /*
            * we use method remove to remove an object from the database table.
            * arguments:
            *   - Model - model we are working with.
            *   - by - object that database will find object to remove by.
            *
            * crud.create([Model], [by])
            * */
            response = await crud.remove('Config', {
                myIP: "127.0.0.1"
            })
            break;
        default:
            // this text will be printed if we try to choose incorrect method.
            console.log("UNKNOWN METHOD!");
            /*
            * BE CAREFUL! CURRENT VERSION OF MODEL HASN'T THE VALIDATION OF METHODS AND PARAMS.
            * */
    }
    // here we print the response of dbMaster.
    console.log('response:', response);
})();

references