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
* takes an array of documents, gets the changes and inserts/updates documents in the database
3372
-
* according to whether or not the document is new, or whether it has changes or not.
3371
+
* Takes an array of documents, gets the changes and inserts/updates documents in the database
3372
+
* according to whether or not the document is new, or whether it has changes or not.
3373
3373
*
3374
3374
* `bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)
3375
3375
*
3376
+
* `bulkSave()` throws errors under the following conditions:
3377
+
*
3378
+
* - one of the provided documents fails validation. In this case, `bulkSave()` does not send a `bulkWrite()`, and throws the first validation error.
3379
+
* - `bulkWrite()` fails (for example, due to being unable to connect to MongoDB or due to duplicate key error)
3380
+
* - `bulkWrite()` did not insert or update **any** documents. In this case, `bulkSave()` will throw a DocumentNotFound error.
3381
+
*
3382
+
* Note that `bulkSave()` will **not** throw an error if only some of the `save()` calls succeeded.
3383
+
*
3376
3384
* @param {Array<Document>} documents
3377
3385
* @param {Object} [options] options passed to the underlying `bulkWrite()`
3378
3386
* @param {Boolean} [options.timestamps] defaults to `null`, when set to false, mongoose will not add/update timestamps to the documents.
3379
3387
* @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](https://mongoosejs.com/docs/transactions.html).
3380
3388
* @param {String|number} [options.w=1] The [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/). See [`Query#w()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.w()) for more information.
3381
3389
* @param {number} [options.wtimeout=null] The [write concern timeout](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout).
3382
3390
* @param {Boolean} [options.j=true] If false, disable [journal acknowledgement](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option)
3383
-
*
3391
+
*@return {BulkWriteResult} the return value from `bulkWrite()`
0 commit comments