bulkUpdate( )


Developer Preview

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:

  • The maximum size of an item that you can update in a collection is 500kb.
  • Bulk operations are limited to 1000 items per method call.
  • The bulkUpdate() method is not supported for single-item collections.
  • The bulkUpdate() method does not support multi-reference fields. For multi-reference fields, use replaceReferences() or insertReference().
  • Translatable collections do not allow insertion and modification of items when working in a non-primary language. For example, if a collection's primary language is English, and the site visitor is viewing the site in French, calling bulkUpdate() fails and issues an error.
Permissions
Write Data Items
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
dataCollectionIdstringRequired

ID of the collection to which the items belong.


itemsArray<WixDataItem>Required

Data items to update.


optionsWixDataOptions

Options to use when processing this operation.

Returns
Return Type:Promise<WixDataBulkResult>
Did this help?