Search...
dropIndex( )
Removes an index from a data collection.
Description
The process of dropping an index from a collection takes time.
You can check whether your index has been dropped by calling listIndexes()
.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function dropIndex(dataCollectionId: string, indexName: string): Promise<void>
dropIndex Parameters
NAME
TYPE
DESCRIPTION
dataCollectionId
string
ID of the data collection for which the index to be dropped is defined.
indexName
string
Name of the index to drop.
Returns
Return Type:
Promise<
void
>Was this helpful?
Drop an index (dashboard page code)
Copy Code
1import { indexes } from "wix-data.v2";23/*4 * Sample dataCollectionId value = 'Jackets'5 *6 * Sample indexName value = 'BySizeAndAvailability'7*/89export async function myDropIndexFunction(dataCollectionId, indexName) {10 try {11 await indexes.dropIndex(dataCollectionId, indexName);12 console.log(`The ${indexName} index is being dropped.`);1314 return;15 } catch (error) {16 console.error(error);17 // Handle the error18 }19}2021/* Promise resolves to void */22
Drop an index (export from backend code)
Copy Code
1import { Permissions, webMethod } from 'wix-web-module';2import { indexes } from 'wix-data.v2';3import { elevate } from 'wix-auth';45/*6 * Sample dataCollectionId value = 'Jackets'7 *8 * Sample indexName value = 'BySizeAndAvailability'9*/101112export const myDropIndexFunction = webMethod(Permissions.Anyone, async (dataCollectionId, indexName) => {13 try {14 const elevatedDropIndex = elevate(indexes.dropIndex);15 await elevatedDropIndex(dataCollectionId, indexName);16 console.log(`The ${indexName} index is being dropped.`);1718 return;19 } catch (error) {20 console.error(error);21 // Handle the error22 }23});2425/* Promise resolves to void */