Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wish: Support Bulk() operations in Mongo 2.6 #2016

Closed
markstos opened this issue Apr 10, 2014 · 7 comments
Closed

wish: Support Bulk() operations in Mongo 2.6 #2016

markstos opened this issue Apr 10, 2014 · 7 comments

Comments

@markstos
Copy link
Contributor

Mongo 2.6 has been released now, and adds new bulk operations.

While the mongoose create() function can insert multiple documents, they are done serially. Mongo has a new option for "unordered inserts" which has the ability to further speed up inserts:

http://docs.mongodb.org/manual/reference/method/Bulk/#Bulk

It would be nice if this was exposed in Mongoose.

Thanks for Mongoose! I'm using it regularly.

@levino
Copy link

levino commented Feb 17, 2016

+1

As far as I can see the inserts are done in parallel but still with individual queries, which is a really bad idea. Should support mongo bulk operation.

@vkarpov15
Copy link
Collaborator

The old initializeUnorderedBulkOp() etc. "fluent bulk" operations are deprecated. The new API for bulk inserts is the insertMany() function. Mongoose has its own thin wrapper around insertMany() as of 4.4.0.

@levino
Copy link

levino commented Feb 18, 2016

Good stuff. Thanks for clarifying.

What about findAndUpdate() or something like updateMany()?

The insertMany() fails if one validation fails. Is there a way to continue anyhow? Matching errors back to which object in the passed array failed the verification would be even nicer.

@vkarpov15
Copy link
Collaborator

There's an ordered option for insertMany() that mongoose needs to properly support, see above issue.

@levino
Copy link

levino commented Feb 19, 2016

Just to clarify: So per default mongoose will continue on error, right?

@vkarpov15
Copy link
Collaborator

No, ordered is true by default and we don't currently have a mechanism for shutting it off, which is why we need #3893.

@raitucarp
Copy link

is this issue resolved? I need ordered option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants