Suggestion - insertMany
See original GitHub issueI have been having a play with inserting array of items.
What I was thinking was if we was able to return as a result the list of successful inserts, along with a list of the failures. At the moment only the first error is returned, and there is no way to tell how many did or didn’t get inserted.
This also then skips the after hooks completely, which means any of the data that was inserted does not go through the hooks.
In my situation I am bulk insert 500 docs at a time and in an after hook I am inserting into elasticsearch, there could be 499 docs inserted and only one error, but the successful inserts will not be sync’d to elasticsearch due to the hook not running.
I would imagine and this isn’t something I have test that the error hook is run, not sure if that will contain the results, but it would mean having the sync hook run in the after and error hook.
Are there plans to integrate the insertMany
method of mongoose/mongo (I believe it to be more performant also), as I understand mongo returns the successful _ids and an array of any errors, I would think mongoose wraps this.
Thoughts?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
Thanks @marshallswain. I’ll see if I can put a PR together or at least a PoC.
@nmajethiya there is an open PR at the moment - https://github.com/feathersjs/feathers-mongoose/pull/199
There are a few issues being discussed at the moment.