https://github.com/rumkin/moongo
Mongo query atomation cli app
https://github.com/rumkin/moongo
Last synced: 5 months ago
JSON representation
Mongo query atomation cli app
- Host: GitHub
- URL: https://github.com/rumkin/moongo
- Owner: rumkin
- Created: 2016-03-25T12:29:03.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-29T09:22:30.000Z (about 10 years ago)
- Last Synced: 2025-02-25T05:34:49.362Z (over 1 year ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Moongo
Moongo is a mongo queries automation tool. All you should to do is create
some scripts and create config file.
## Installation
```shell
npm i moongo -g
```
## Example
Create script `moongo/update-counters.js`:
```javascript
// 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:
```bash
$ 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:
```javascript
{
"connections": {
"local": {
"host": "localhost",
"port": 27017,
"base": "my-base",
"confirm": false
}
}
}
```
### Connection options
| Option | Type | Desc |
|:--------|:---------|:-----------------------------------------------|
| host | `string` | MongoDB host |
| port | `number` | MongoDB port |
| base | `string` | Database name |
| confirm | `bool` | Force confirmation prompt to prevent accidents |