bulkRemove( )
Removes a number of items from a collection.
Description
The bulkRemove()
function returns a Promise that resolves after the items
have been removed from the specified collection.
The Promise is rejected if the current user does not have "delete" permissions
for the collection. If the delete permissions for the collection are set to
Site member author, the only items that will be deleted are those for
which the current user is the owner. All other items will be skipped.
Calling the bulkRemove()
function triggers the beforeRemove()
and afterRemove()
hooks for each item
that is deleted if the hooks have been defined.
Use the options
parameter to run bulkRemove()
from backend code without
checking for permissions or without its registered hooks.
Notes:
The
bulkRemove()
function also clears multiple-item reference fields for items in collections referenced by the specified items. For example, suppose you have a Movies collection with an Actors field that contains multiple references to items in a People collection. Removing items in the Movies collection also clears the data in the corresponding multiple-item reference fields in the People collection.Bulk operations are limited to 1000 items per function call.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - The results of the bulk remove. Rejected - The error that caused the rejection.
NAME
TYPE
DESCRIPTION
The number of removed items.
The number of skipped items.
List of IDs of removed items.
List of errors.
Status/Error Codes
Was this helpful?
1import wixData from 'wix-data';23// ...45let toRemove = ["00001", "00003", "00004"];67wixData.bulkRemove("myCollection", toRemove)8 .then((results) => {9 let removed = results.removed; // 210 let removedIds = results.removedItemIds; // see below11 let skipped = results.skipped; // 012 })13 .catch((err) => {14 let errorMsg = err;15 });1617/* removedIds is:18 *19 * [20 * "00001",21 * "00002",22 * "00003"23 * ]24 */
1import wixData from 'wix-data';23// ...45let toRemove = ["00001", "00003", "00004"];67let options = {8 "suppressAuth": true,9 "suppressHooks": true10};1112wixData.bulkRemove("myCollection", toRemove, options)13 .then((results) => {14 let removed = results.removed; // 215 let removedIds = results.removedItemIds; // see below16 let skipped = results.skipped; // 017 })18 .catch((err) => {19 let errorMsg = err;20 });2122/* removedIds is:23 *24 * [25 * "00001",26 * "00002",27 * "00003"28 * ]29 */