Removes an index from a data collection.
The process of dropping an index from a collection takes time. You can check whether an index has been dropped by calling List Indexes.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function dropIndex(
dataCollectionId: string,
indexName: string,
options: DropIndexOptions,
): Promise<void>;
ID of the data collection for which the index to be dropped is defined.
Name of the index to drop.
Options for dropping an index.
import { indexes } from "wix-data.v2";
/*
* Sample dataCollectionId value = 'Jackets'
*
* Sample indexName value = 'BySizeAndAvailability'
*/
export async function myDropIndexFunction(dataCollectionId, indexName) {
try {
await indexes.dropIndex(dataCollectionId, indexName);
console.log(`The ${indexName} index is being dropped.`);
return;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to void */
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.