Search...
deleteDataCollection( )
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";23// Deleting the collection whose _id is "myMusicCollection":4// const dataCollectionId = "myMusicCollection"56export async function myDeleteDataCollectionFunction(dataCollectionId) {7 try {8 await collections.deleteDataCollection(dataCollectionId);9 return;10 } catch (error) {11 console.error(error);12 // Handle the error13 }14}1516/* 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';34// Deleting the collection whose _id is "myMusicCollection":5// const dataCollectionId = "myMusicCollection"67export const myDeleteDataCollectionFunction = webMethod(Permissions.Anyone, async (dataCollectionId) => {8 try {9 await collections.deleteDataCollection(dataCollectionId);10 return;11 } catch (error) {12 console.error(error);13 // Handle the error14 }15});1617/* Promise resolves to void */18