Search.../

deleteDataCollection( )

Developer Preview

Deletes a data collection.

Description

Note: Once a collection is deleted, it can't be restored.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function deleteDataCollection(dataCollectionId: string): Promise<void>

deleteDataCollection Parameters

NAME
TYPE
DESCRIPTION
dataCollectionId
string

ID of the collection to delete.

Returns

Return Type:

Promise<
void
>

Was this helpful?

Delete an existing collection (dashboard page code)

Copy Code
1import { collections } from "wix-data.v2";
2
3// Deleting the collection whose _id is "myMusicCollection":
4// const dataCollectionId = "myMusicCollection"
5
6export async function myDeleteDataCollectionFunction(dataCollectionId) {
7 try {
8 await collections.deleteDataCollection(dataCollectionId);
9 return;
10 } catch (error) {
11 console.error(error);
12 // Handle the error
13 }
14}
15
16/* Promise resolves to void */
Delete an existing collection (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { collections } from 'wix-data.v2';
3
4export const myDeleteDataCollectionFunction = webMethod(Permissions.Anyone, async (dataCollectionId) => {
5 try {
6 await collections.deleteDataCollection(dataCollectionId);
7 return;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12});
13
14/* Promise resolves to void */
15