Lists all indexes defined for a data collection.
When an index's status is ACTIVE
, it is ready to use.
While it is still being created, its status is BUILDING
.
When an index's status is DROPPED
, it has been dropped successfully.
While it is still in the process of being removed, its status is DROPPING
.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function listIndexes(
dataCollectionId: string,
options: ListIndexesOptions,
): Promise<ListIndexesResponse>;
ID of the data collection for which to list indexes.
Options for retrieving a list of indexes.
import { indexes } from "wix-data.v2";
/*
* Sample dataCollectionId value = 'Jackets'
*
* Sample options value = {
* limit: 5
* }
*/
export async function myListIndexesFunction(dataCollectionId, options) {
try {
const listIndexesResponse = await indexes.listIndexes(
dataCollectionId,
options,
);
console.log(
`List of indexes for this collection: ${listIndexesResponse.indexes}`,
);
return listIndexesResponse;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to a list of indexes for the specified collection, with paging metadata:
* {
* "indexes": [
* {
* "caseInsensitive": true,
* "fields": [
* {
* "order": "ASC"
* "path": "itemName",
* },
* {
* "order": "DESC"
* "path": "size",
* }
* ],
* "name": "byItemNameAndSize",
* "status": "ACTIVE",
* "unique": false,
* },
* {
* "caseInsensitive": false
* "fields": [
* {
* "order": "ASC"
* "path": "size",
* },
* {
* "order": "DESC"
* "path": "available",
* }
* ],
* "name": "bySizeAndAvailability",
* "status": "ACTIVE",
* "unique": false,
* }
* ],
* "pagingMetadata": {
* "count": 2,
* "offset": 0,
* "total": 2,
* "tooManyToCount": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.