Model.create(doc, fn) should save all valid documents.
See original GitHub issueI’m trying to save a set of documents using Model.create(documents, function(error){...})
I found when a document is invalid, the previous documents were saved but the following will never be saved.
I think Model.create should save all valid documents. I would like an API like this.
//Passing one doc
Person.create({name: "John"}, function(error, john){...})
//Passing an array
var persons = [{name: "John"}, {name: "Doe"}];
Person.create(persons, function(errors, docs){...});
//Passing individual docs
Person.create({name: "John"}, {name: "Doe"}, function(errors, docs){...});
I would like to do a pull request, but first I want to know what do you think.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
Saving multiple documents with Mongoose and doing ...
When the last document is saved, I want to report (i.e. send an event) that all documents have been saved. The way I'm...
Read more >Mongoose v6.8.1: Model
Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs. This function triggers the ......
Read more >An Introduction to Mongoose's `save()` Function - Mastering JS
When you create an instance of a Mongoose model using new , calling save() makes Mongoose insert a new document. const Person =...
Read more >Model Querying - Basics - Sequelize
Simple INSERT queries ... const jane = await User.create({ firstName: "Jane", lastName: "Doe" }); console.log("Jane's auto-generated ID:", jane.
Read more >wither::model::Model - Rust - Docs.rs
API documentation for the Rust `Model` trait in crate `wither`. ... fn save(&mut self, db: Database, filter: Option<Document>) -> Result<()> { ... }....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
sounds good to me. I’ll take a stab at it.
@lineus we could just add a list of saved docs and a list of docs that failed to save in the error. Thoughts?