This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Inserts or updates a number of items in a collection.
The bulkSave()
method returns a Promise that resolves after the items
have been added or updated in the specified collection. The Promise is
rejected if the current user does not have the necessary permissions for the
collection.
The bulkSave()
method inserts or updates the specified items, depending
on whether they already exist in the collection. It compares the _id
property value of the specified items with the _id
property values of the
items in the specified collection.
_id
value, bulkSave()
uses update()
to update the item in the collection, triggering the
beforeUpdate()
and afterUpdate()
hooks for that item if they have been
defined._id
value, the
specified item does not have an _id
property, or if the specified item's
_id
property is undefined
, bulkSave()
uses insert()
to add the
specified item into the collection. This triggers the beforeInsert()
and afterInsert()
hooks for that item if they have been defined.When saving items to a collection that has a reference field, set the values
of the reference fields to the referenced item's _id
value or the entire
referenced item object.
Notes:
_id
property value is set to null or an empty string, an error is thrown.bulkSave()
method is not supported for single-item collections.bulkSave()
method does not support multi-reference fields. For multi-reference fields, use replaceReferences()
or insertReference()
.bulkSave()
fails and issues an error.
ID of the collection to which the items belong.
Data items to save.
Options to use when processing this operation.