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";
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
5/*
6 * Sample dataCollectionId value = 'Jackets'
7 *
8 * Sample indexName value = 'BySizeAndAvailability'
9*/
10
11
12export 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.`);
17
18 return;
19 } catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23});
24
25/* Promise resolves to void */