powmedia/pow-mongodb-fixtures — pull request #4 by hiddentao (2012-04-20 09:32:57+00:00)
Title: Modifiers

This is an implementation of the concept of modifiers specified in https://github.com/powmedia/pow-mongodb-fixtures/issues/3.

To recap:

For my use case, I want to be able to add some properties to my fixture data at run-time prior to it being inserted into the database. I'm thinking of adding the concept of filters to do this.

So you might do something like this:

```
var fixtures = require('pow-mongodb-fixtures').connect(app.db.name, app.

fixtures.addModifier(function(collectionName, doc, cb) {
doc.createdAt = new Date();
cb(null, doc);
});

fixtures.load(__dirname + '/../db/fixtures', function(err) {
```

The signature of the filter method:

```
/**
*
* @param collectionName the name of the collection to which the doc is going to be inserted.
* @param doc the doc which is going to be inserted.
* @param cb callback with signature (err, modifiedDoc)
*/
```

Tests updated and added.