https://github.com/coderaiser/node-mongomery
Generator based flow-control driver for MongoDB
https://github.com/coderaiser/node-mongomery
Last synced: 9 months ago
JSON representation
Generator based flow-control driver for MongoDB
- Host: GitHub
- URL: https://github.com/coderaiser/node-mongomery
- Owner: coderaiser
- License: mit
- Created: 2015-04-01T20:32:38.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-24T19:38:34.000Z (over 10 years ago)
- Last Synced: 2025-05-19T02:48:03.460Z (11 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 18
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
Mongomery
=======
Generator based flow-control driver for [MongoDB](http://mongodb.org "MongoDB").
`Mongomery` has API like [mongodb-native](https://github.com/mongodb/node-mongodb-native "MongoDB Native") has, but based on `es6 generators`.
## Install
`npm i mongomery --save`
## How come?
With help of `ES6` generators flow-control of interaction with `MongoDB` could be much simpler.
`Mongomery` will save your code from [callback hell](http://callbackhell.com/ "Callback Hell").
## Hot to use?
```js
var mongomery = require('mongomery');
mongomery(function*(mongo) {
var url = 'mongodb://localhost:27017/myproject',
db = yield mongo.connect(url),
collection = db.collection('mongolog'),
docs = yield collection.find({}).toArray();
docs.forEach(function(item) {
console.log(item);
});
db.close();
}).on('error', function(error) {
console.log(error.message);
});
```
## License
MIT