0.0.6 • Published 5 years ago
rongo v0.0.6
Rongo
https://github.com/ristika/rongo
https://www.npmjs.com/package/rongo
A simple wrapper with limited (but most of what you might need) for the official MongoDB Node.js driver
Ideal for replica sets and allowing the client to manage and persist connections rather than creating one on each call.
For information on using the mongo with express see: https://www.ristika.com/search?keyword=express;mongo.
To use:
Import the package via npm - var rongo = require('rongo');
Set your global DBAddresses object:
global.DBAddresses = {
read: 'localhost:27017/' + dbName,
write: 'localhost:27017/' + dbName
};
or
global.DBAddresses = {
read: 'replica0:27017/' + dbName,
write: 'replica1:27017/' + dbName
};
Call rongo.setUpDBs('dbname');
Rongo can now be passed around and used in places like:
rongo.collection('acoll').find({ name: name }, (err, docs) => callbackFunc);
To do:
Return promises rather than using callbacks
Add a util function to determine a write address
Manage state within rongo, updating the dbs etc
Add linting