Removes all items from a collection.
truncate() function returns a Promise that resolves
after all items have been removed from the specified collection.
truncate() runs when at least one of the following is true:
- The current user is the site owner.
- The request is performed in backend code with a
suppressAuthoptions value of
truncate() function does not trigger any hooks.
truncate()also clears multiple-item reference fields in collections referenced by the specified collection. For example, suppose you have a Movies collection with an Actors field that contains multiple references to items in a People collection. Truncating the Movies collection also clears the data in the corresponding multiple-item reference field in the People collection.
function truncate(collectionName: string, [options: WixDataOptions]): Promise<void>
The collection to remove items from.
An object with the following boolean property: suppressAuth.
Fulfilled - When the items have been removed. Rejected - The error that caused the rejection.
Was this helpful?