This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a number of items in a collection.
The bulkUpdate()
method returns a Promise that resolves after the items
have been updated in the specified collection. The Promise is rejected if
the current user does not have update permissions for the collection. Items
are skipped if they include an _id
property whose value does not match an
existing ID in the collection. Meaning, bulkUpdate()
cannot add new items
into the collection.
Calling the bulkUpdate()
method triggers the beforeUpdate()
and afterUpdate()
hooks for each item that is updated if the hooks have been defined.
The bulkUpdate()
method compares the _id
property of the specified items with the _id
property values of the items in the specified collection.
Warning:
If an existing item in the specified collection matches the _id
of the specified item, bulkUpdate()
replaces the existing item's property values with the ones in the specified item. If the existing item had properties with values and those properties are not included in the specified item, the values in those properties are lost.
The item's _updatedDate
property is also updated to the current date.
Any valid JavaScript object can be used as a property value. The
bulkUpdate()
method maintains the structure of the specified object. For
example, objects that contain nested objects, arrays, or arrays with nested
objects are all added to the collection as defined.
When updating items in a collection that has a reference field, set the
values of the reference field to the referenced item's _id
value or the
entire referenced item object.
Notes:
bulkUpdate()
method is not supported for single-item collections.bulkUpdate()
method does not support multi-reference fields. For multi-reference fields, use replaceReferences()
or insertReference()
.bulkUpdate()
fails and issues an error.
ID of the collection to which the items belong.
Data items to update.
Options to use when processing this operation.