backbone-db-mongodb

MongoDB driver for Backbone.Db

npm install backbone-db-mongodb
29 downloads in the last day
163 downloads in the last week
559 downloads in the last month

Usage

Build Status

var MongoDB = require('backbone-db-mongodb');
var Model = require('backbone-promises').Model;
var store = new MongoDB(mongoClient);

var MyModel = Model.extend({
  db: store,
  sync: store.sync,
  mongo_collection: 'mymodels'
});

var a = new MyModel({id:"1", "data":123});

a.save().then(function() {
  var b = new Model({id:1});
  return b.fetch().then(function() {
    console.log(a.get("data"),b.get("data"));
  });
}).otherwise(console.error.bind(console));
npm loves you