node-mongoose-fixtures icon indicating copy to clipboard operation
node-mongoose-fixtures copied to clipboard

Adding support for function-type saved datasets

Open mgiamberardino opened this issue 7 years ago • 1 comments

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 */);

mgiamberardino avatar Oct 09 '18 17:10 mgiamberardino

Sorry, I did not see this.

This is awesome! Can you add some documentation to the README.md and a test?

kennethklee avatar Jan 09 '20 18:01 kennethklee