miffo
v0.2.3
Published
Just another wrapper for the mongodb native driver in node.js
Readme
miffo
Wrapper for the mongodb native driver in node.js. Trying to stay as close as possible to the shell API.
Features
- Use as a simple wrapper or with konstapel for authentication middleware.
- Uses bcrypt to hash passwords.
- See the mongodb docs for a complete syntax.
Install
$ npm install miffoUsage
var Miffo = require('miffo'),
url = 'mongodb://user:pwd@url:port/db',
collections = ['users', 'items'],
db = new Miffo(url, collections);
// connect
db.start(<cb>); // logs on success and throws otherwise. Pass cb to do async.
// wrapper API
db[collectionName].query({selectors}, {projections}, cb(err, data));
// Methods
db.oid() // new mongo-style ObjectID
db.oid(id) // ObjectID from string
oid.toHexString() // hex from ObjectID
db.bcrypt.hash() // hash pwd (See bcrypt for details)
db.bcrypt.compare() // compare pwds
// close
db.connection.close(); // the return object from mongo.connect is stored on db.connectionTest
# All tests pass. Needs auth data from settings.json for query operations.
$ npm testLicence
MIT
