0.2.1 • Published 8 years ago

moongo v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Moongo

Moongo is a mongo queries automation tool. All you should to do is create some scripts and create config file.

Installation

npm i moongo -g

Example

Create script moongo/update-counters.js:

// moongo/update-counters.js
module.exports = function($api, type, inc, dec) {
    var col = $api.collection('counters');

    if (inc !== 'undefined') {
        return col.update({
            type
        }, {
            $inc: inc
        });
    }
    else if (dec !== 'undefined') {
        return col.update({
            type
        }, {
            $inc: dec
        });
    }
    else {
        throw new Error('No inc or dec param specified');
    }
};

Run script:

$ cd moongo
$ moongo run local update-counters.js type=active inc=1 # -> ok
$ moongo run local update-counters.js type=inactive dec=1 # -> ok
$ moongo run local update-counters.js type=inactive # -> No inc or dec param specified

Config

Configuration file should contain connections:

{
    "connections": {
        "local": {
            "host": "localhost",
            "port": 27017,
            "base": "my-base",
            "confirm": false
        }
    }
}

Connection options

OptionTypeDesc
hoststringMongoDB host
portnumberMongoDB port
basestringDatabase name
confirmboolForce confirmation prompt to prevent accidents