You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/model.js
+28-8Lines changed: 28 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2079,6 +2079,11 @@ var INSERT_MANY_CONVERT_OPTIONS = {
2079
2079
* because it only sends one operation to the server, rather than one for each
2080
2080
* document.
2081
2081
*
2082
+
* Mongoose always validates each document **before** sending `insertMany`
2083
+
* to MongoDB. So if one document has a validation error, no documents will
2084
+
* be saved, unless you set
2085
+
* [the `ordered` option to false](https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/#error-handling).
2086
+
*
2082
2087
* This function does **not** trigger save middleware.
2083
2088
*
2084
2089
* This function triggers the following middleware:
@@ -2091,6 +2096,8 @@ var INSERT_MANY_CONVERT_OPTIONS = {
2091
2096
*
2092
2097
* @param {Array|Object|*} doc(s)
2093
2098
* @param {Object} [options] see the [mongodb driver options](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany)
2099
+
* @param {Boolean} [options.ordered = true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`.
2100
+
* @param {Boolean} [options.rawResult = false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `false`, will return the [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~insertWriteOpCallback) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
0 commit comments