Search.../

dropIndex( )

Developer Preview

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";
2
3/*
4 * Sample dataCollectionId value = 'Jackets'
5 *
6 * Sample indexName value = 'BySizeAndAvailability'
7*/
8
9export async function myDropIndexFunction(dataCollectionId, indexName) {
10 try {
11 await indexes.dropIndex(dataCollectionId, indexName);
12 console.log(`The ${indexName} index is being dropped.`);
13
14 return;
15 } catch (error) {
16 console.error(error);
17 // Handle the error
18 }
19}
20
21/* 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';
4
5export const myDropIndexFunction = webMethod(Permissions.Anyone, async (dataCollectionId, indexName) => {
6 try {
7 const elevatedDropIndex = elevate(indexes.dropIndex);
8 await elevatedDropIndex(dataCollectionId, indexName);
9 console.log(`The ${indexName} index is being dropped.`);
10
11 return;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to void */