This package has been deprecated

Author message:

use node-mongodb-native

mongo-test-db

0.3.3 • Public • Published

mongo-test-db

Small utility to load database connections and fixtures suitable for testing.

Usage

Simplest use case without fixtures

var MongoTestDb = require('mongo-test-db');
var db = new MongoTestDb();

db.open(function (err) {
  // do some stuff with db.connection
});

Example with fixtures and options

var MongoTestDb = require('mongo-test-db');
var db = new MongoTestDb({
  dbHost: '10.0.0.123', // defaults to "127.0.0.1" if omitted
  dbPort: 27009,        // defaults to 27017 if omitted
  dbName: 'myDb',       // defaults to "test" if omitted
  dbUser: 'joe',        // optional
  dbPass: 'secret'      // optional
});

var fixtures = {
  myCollection: [
    { foo: 'bar' },
    { qux: 'raboof' }
  ]
}

db.open(fixtures, function (err) {
  // now a collection named "myCollection" is created that contains two
  // items
  // raw connection available at db.connection
});

Installation

$ npm install mongo-test-db

License

MIT, see LICENSE

Readme

Keywords

none

Package Sidebar

Install

npm i mongo-test-db

Weekly Downloads

0

Version

0.3.3

License

MIT

Last publish

Collaborators

  • timkuijsten