0.2.3 • Published 8 years ago
miffo v0.2.3
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 miffo
Usage
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.connection
Test
# All tests pass. Needs auth data from settings.json for query operations.
$ npm test
Licence
MIT