question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion - insertMany

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Mattchewonecommented, Jun 8, 2017

Thanks @marshallswain. I’ll see if I can put a PR together or at least a PoC.

0reactions
Mattchewonecommented, Jun 26, 2017

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A suggestion for 'Creating Documents: insertMany()' - MongoDB
I ran ordered query for insertMany(one provided in handouts:insertMany-ordered.js). In lecture video, instructor's query resulted in ...
Read more >
MongoDB Bulk Insert - MongoDB insertMany - DigitalOcean
Lets see an example of how to insert multiple documents using mongodb bulk insert through command line. MongoDB insert many documents. > db.car....
Read more >
How is insertMany different to collection.insert in Mongoose?
I scouted around to find the right solution for inserting a large amount of documents to MongoDB using Mongoose.
Read more >
10 - Save document using create() and insertMany() - YouTube
Find the source code here -https://bushansirgur.in/nodejs-express-mongoose-and-mongodb-restful-web-service-post-request/Complete ...
Read more >
How To Insert Document In Collection || insertOne || insertMany
$GTii HISTORICAL Upside In Play! Statistical Physics Suggest Up! Arca. Arca. •.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found