node-mongoose-fixtures
node-mongoose-fixtures copied to clipboard
Adding support for function-type saved datasets
Feature
The main idea is to be able to save named datasets accepting functions where you can create your datasets based on some extra data given by parameter when creating the fixture.
How to use it
fixtures.save('theName', ({ user }) => {
const userId = user._id;
return {
entry: [{
_id: '123456',
user: userId,
data: ...,
}],
};
});
...
fixtures({
datasetName: 'theName',
datasetExtras: { user: { _id: 'the_user_id' } },
}, .../* the usual callback */);
Sorry, I did not see this.
This is awesome! Can you add some documentation to the README.md and a test?