> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: data.items.bulkUpdate(dataCollectionId: string, items: Array, options: WixDataBulkUpdateOptions) # Method Link: https://dev.wix.com/docs/sdk/business-solutions/data/items/bulk-update.md # Method Description: 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()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/before-update.md) and [`afterUpdate()`](https://dev.wix.com/docs/velo/api-reference/wix-data/hooks/after-update.md) 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 does not support multi-reference fields. For multi-reference fields, use `replaceReferences()` or `insertReference()`. > - [Translatable collections](https://support.wix.com/en/article/wix-multilingual-translating-cms-collection-content) 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. # Method Permissions: - Write Data Items # Method Permissions Scopes IDs: - SCOPE.DC-DATA.WRITE # Method Code Examples: ## Update multiple items with specified IDs in a collection ```javascript import { items } from "@wix/data"; async function bulkUpdateItems() { const toUpdate1 = { "_id": "00001", "title": "Mr.", "first_name": "John", "last_name": "Doe" }; const toUpdate2 = { "_id": "00002", "title": "Ms.", "first_name": "Jane", "last_name": "Doe" }; const results = await items.bulkUpdate("myCollection", [toUpdate1, toUpdate2]); const inserted = results.inserted; // 0 const insertedIds = results.insertedItemIds; // [] const updated = results.updated; // 2 const skipped = results.skipped; // 0 const errors = results.errors; // [] } ``` ## Update multiple items including a reference to another item using the referenced item's ID ```javascript import { items } from "@wix/data"; async function bulkUpdateItems() { const countryId = "id-of-usa-item"; const toUpdate1 = { "_id": "00001", "title": "Mr.", "first_name": "John", "last_name": "Doe", "country": countryId }; const toUpdate2 = { "_id": "00002", "title": "Ms.", "first_name": "Jane", "last_name": "Doe", "country": countryId }; const results = await items.bulkUpdate("myCollection", [toUpdate1, toUpdate2]); const inserted = results.inserted; // 0 const insertedIds = results.insertedItemIds; // [] const updated = results.updated; // 2 const skipped = results.skipped; // 0 const errors = results.errors; // [] } ``` ## Update multiple items including a reference to another item using the referenced item ```javascript import { items } from "@wix/data"; async function bulkUpdateItems() { const countryItem = // get country item from somewhere const toUpdate1 = { "_id": "00001", "title": "Mr.", "first_name": "John", "last_name": "Doe", "country": countryItem }; const toUpdate2 = { "_id": "00002", "title": "Ms.", "first_name": "Jane", "last_name": "Doe", "country": countryItem }; const results = await items.bulkUpdate("myCollection", [toUpdate1, toUpdate2]); const inserted = results.inserted; // 0 const insertedIds = results.insertedItemIds; // [] const updated = results.updated; // 2 const skipped = results.skipped; // 0 const errors = results.errors; // [] } ``` ## Update multiple items with condition ```javascript import { items } from "@wix/data"; async function bulkUpdateItems() { const toUpdate1 = { "_id": "00001", "title": "Mr.", "first_name": "John", "last_name": "Doe", "active": true }; const toUpdate2 = { "_id": "00002", "title": "Ms.", "first_name": "Jane", "last_name": "Doe", "active": true }; const filter = items.filter().eq("active", false); const results = await items.bulkUpdate("Users", [toUpdate1, toUpdate2], { condition: filter }); const inserted = results.inserted; // 0 const insertedIds = results.insertedItemIds; // [] const updated = results.updated; // 2 const skipped = results.skipped; // 0 const errors = results.errors; // [] } ``` ## default ```javascript try { const result = await items.bulkUpdate("collection-0.37714571445076217", [ { _id: "6892593d-d57f-428d-bc53-3f0870a1beef", _owner: "28962158-e9e0-4a9c-8bf0-5f654d78ccb6" } ], { appOptions: {}, showDrafts: false, suppressHooks: false }); return result; } catch (error) { console.error(error); throw error; } ```