arboria

A fixture loader for mongo (that doesn't db.open)

Arboria

A fixture loader for mongo (that doesn't db.open)

Example

 
var arboria = require('arboria');
 
var mongodb = require('mongodb');
var Server = mongodb.Server;
var MongoClient = mongodb.MongoClient;
 
var server = new Server('localhost', '27017', { native_parser: true });
var connection = new MongoClient(server);
 
connection.open(function(errmongoClient) {
  
  var a = arboria(mongoClient.db('test-db'));
  var fixture = a.fixture('test-collection');
 
});
 
  
fixture
  .add({ name: "Shane", age: 25 })
  .add({ name: "Robert", age: 23 })
  .done(function(errdata) {
    console.log('added Shane and Robert');
  });
 
 
fixture
  .remove({ name: "Robert", age: 23 })
  .done(function(errdata) {
    console.log('removed Robert.');
  });
 
 
fixture
  .add('justin')
  .remove({ name: "Shane", age: 25 })
  .done(function(errdata) {
    console.log('added Justin from \'/test/fixtures/justin.json\' and removed Shane.');
  });