mongodb persistence engine for save

npm install save-mongodb
3 downloads in the last day
32 downloads in the last week
79 downloads in the last month

save-mongodb - mongodb persistence engine for save


  npm install save-mongodb


I won't boar your with waffle. If you want to see how this works look at the tests or this simple example:

// What you'll need!
var Db = require('mongodb').Db // npm install mongodb
  , Server = require('mongodb').Server
  , save = require('save') // npm install save
  , saveMongodb = require('..')

  // Create a db object to a local mongodb database called SimpleExample.
  , db = new Db('SimpleExample', new Server('localhost', 27017, {}));

// Open your mongodb database. (error, connection) {

  // Get a collection. This will create the collection if it doesn't exist.
  connection.collection('contact', function (error, collection) {

    // Create a save object and pass in a mongodb engine.
    var contactStore = save('Contact', { engine: saveMongodb(collection) });

    // Then we can create a new object.
    contactStore.create({ name: 'Paul', email: ''}, function (error, contact) {

      // The created 'contact' is returned and has been given an _id

      // Don't forget to close your database connection!



Paul Serby follow me on twitter @serby


Licenced under the New BSD License

npm loves you