tdegrunt/mongodb-fixtures — pull request #2 by clintharris (2012-01-19 01:50:17+00:00)
Title: Allow load() and/or save() to be called more than once

Proposed fix for issue #1.

Would be great if you would consider pulling these changes so that people can load and save fixtures repeatedly (for example, setup/teardown functions in unit or integration tests).

Note that this does modify the API a bit; `load()` returns fixture data, and `save()` saves the fixture data passed as a parameter. Example:

```javascript
var fixtures = require('mongodb-fixtures');
//...
var data = fixtures.load();
fixtures.save(data, db, function() {
db.close();
console.dir(data);
});
```

Here's an example of how this can be really helpful:

```javascript
var nodeunit = require('nodeunit');
var fixtures = require('mongodb-fixtures');
module.exports = nodeunit.testCase({

setUp: function (setUpFinished) {
testdata = fixtures.load('./my_db-fixture_files');
mongodb_fixtures.save(testdata, mongoose.connection.db, function() {
setUpFinished();
});
},

'test #1': function (test) { ... },

'test #2': function (test) { ... }
});
```

Thanks!