feat/Add support for Model.insertMany #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The plugin didn't support pre-hook for
insertMany
event, so it has been added.Colses the issue #23 .
Changes include:
insertMany
processDocumentsOnInsertMany
function and its tests for better coverageprocessDocumentsOnInsertMany
does the vary same as a callback, passed to post-save hook with the only difference that it receives document-objects array and getting/setting fields is performed on each document andnext
is called only if the last document has been processed.describe.each
,it.each
.insertMany
should be tested with an array of documents, but tests would be the same as with testingnew Model
, the following has been made:createDocumentWithNewModel
&createDocumentsWithInsertMany
, each receiving an array of docs with a difference thatcreateDocumentWithNewModel
also receiving an array, but only one document from there will be processed. Array of documents is used in both suites to allowdescribe.each
to properly work.vars
, function declarations instead of expressions/arrow functions);P.S. another good idea to unite both hooks would have been to use
validate
since it triggered in both cases.If this PR still seems too hard to follow along, it is possible to discuss over Skype, Whatsapp, or anything similar.