npm.io
0.1.3 • Published 11 years ago

mongoose-load-fixtures

Licence
MIT
Version
0.1.3
Deps
4
Vulns
13
Weekly
0

Mongoose fixtures loader

Build Status Dependency Status

This fixture loader is a rewrite of from https://github.com/powmedia/mongoose-fixtures to pass inserted items to callback, be a bit more flexible about fixtures input formats, and use dropCollection OR emptyCollection as an option.

Syntax : loadFixtures(fixturesObject, opts, cb)

fixturesObject is an object {ModelName: fixtures, ModelName: fixtures, ...}

For each model, fixtures can be :

  • an array of objects [ {item1: {item1 data}, item2: {item2 data}}, {item9: {item9 data}}] or strings (path to a file which is imported, exported values have to be an object)
  • an object {item1: {item1 data}, item2: {item2 data}}
  • a string (path to a file which is imported, exported values have to be an object)

opts can be:

  • db : mongoose connection to use
  • perCollectionLimit : max concurrent collections to process
  • perDocumentLimit : max concurrent document (PER COLLECTION) to process

TODO: if cb is null, a promise should be returned TODO: add options to drop / empty / keep collection TODO: check indexes

Keywords