Search...
listIndexes( )
Lists all indexes defined for a data collection.
Description
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
.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function listIndexes(dataCollectionId: string, options: ListIndexesOptions): Promise<ListIndexesResponse>
listIndexes Parameters
NAME
TYPE
DESCRIPTION
dataCollectionId
string
ID of the data collection for which to list indexes.
options
Optional
ListIndexesOptions
Options for retrieving a list of indexes.
Returns
Return Type:
Promise<
ListIndexesResponse
>NAME
TYPE
DESCRIPTION
indexes
Array<
Index
>List of all indexes for the requested data collection.
pagingMetadata
PagingMetadata
Paging metadata
Was this helpful?
List indexes (dashboard page code)
Copy Code
1import { indexes } from "wix-data.v2";23/*4 * Sample dataCollectionId value = 'Jackets'5 *6 * Sample options value = {7 * limit: 58 * }9*/1011export async function myListIndexesFunction(dataCollectionId, options) {12 try {13 const listIndexesResponse = await indexes.listIndexes(dataCollectionId, options);14 console.log(`List of indexes for this collection: ${listIndexesResponse.indexes}`);1516 return listIndexesResponse;17 } catch (error) {18 console.error(error);19 // Handle the error20 }21}2223/* Promise resolves to a list of indexes for the specified collection, with paging metadata:24* {25* "indexes": [26* {27* "caseInsensitive": true,28* "fields": [29* {30* "order": "ASC"31* "path": "itemName",32* },33* {34* "order": "DESC"35* "path": "size",36* }37* ],38* "name": "byItemNameAndSize",39* "status": "ACTIVE",40* "unique": false,41* },42* {43* "caseInsensitive": false44* "fields": [45* {46* "order": "ASC"47* "path": "size",48* },49* {50* "order": "DESC"51* "path": "available",52* }53* ],54* "name": "bySizeAndAvailability",55* "status": "ACTIVE",56* "unique": false,57* }58* ],59* "pagingMetadata": {60* "count": 2,61* "offset": 0,62* "total": 2,63* "tooManyToCount": false64* }65* }66*/67
List indexes (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 options value = {9 * limit: 510 * }11*/1213export const myListIndexesFunction = webMethod(Permissions.Anyone, async (dataCollectionId, options) => {14 try {15 const elevatedListIndexes = elevate(indexes.listIndexes);16 const listIndexesResponse = await elevatedListIndexes(dataCollectionId, options);17 console.log(`List of indexes for this collection: ${listIndexesResponse.indexes}`);1819 return listIndexesResponse;20 } catch (error) {21 console.error(error);22 // Handle the error23 }24});2526/* Promise resolves to a list of indexes for the specified collection, with paging metadata:27* {28* "indexes": [29* {30* "caseInsensitive": true,31* "fields": [32* {33* "order": "ASC"34* "path": "itemName",35* },36* {37* "order": "DESC"38* "path": "size",39* }40* ],41* "name": "byItemNameAndSize",42* "status": "ACTIVE",43* "unique": false,44* },45* {46* "caseInsensitive": false47* "fields": [48* {49* "order": "ASC"50* "path": "size",51* },52* {53* "order": "DESC"54* "path": "available",55* }56* ],57* "name": "bySizeAndAvailability",58* "status": "ACTIVE",59* "unique": false,60* }61* ],62* "pagingMetadata": {63* "count": 2,64* "offset": 0,65* "total": 2,66* "tooManyToCount": false67* }68* }69*/70