Yet another mongodb facade.

npm install mniam
12 downloads in the last week
24 downloads in the last month

Build Status Dependency Status NPM version


Yet another mongodb native driver facade. Takes care of:

  • mongo URI parsing
  • opening and closing DB connections
  • opening collections

Install by running

npm install mniam


database(url, [options])

Connect to database mniam-test and create friends collection with index on name field.

var db = database('mongodb://localhost/mniam-test'),
  friends = db.collection({
    name: 'friends',
    indexes: [[{ name: 1 }]]

Mniam is using MongoClient to establish the connection: full mongo database URLs are supported. The database function also takes a hash of options divided into db/server/replset/mongos allowing you to tweak options not directly supported by the unified url string format.

var db = database('mongodb://localhost/mniam-test', {
  db: {
    w: -1
  server: {
    ssl: true

Add a new documents:{
  name: 'Alice',
  age: 14,
}, function(err, item) {
    console.log('Item id:', item._id);


Update a document:

friends.findAndModify(item._id, {
  $set: { age: 15 }
}, function(err, item) {
  console.log('Alice is now:', item.age);


Remove a document:

friends.remove({ name: 'Alice' }, function(err) {
  // last collection closed closes DB connection

Other collection methods supported

  • collection.geonear
  • forEach
  • collection.findOne
  • collection.update



npm loves you