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";
2
3/*
4 * Sample dataCollectionId value = 'Jackets'
5 *
6 * Sample options value = {
7 * limit: 5
8 * }
9*/
10
11export 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}`);
15
16 return listIndexesResponse;
17 } catch (error) {
18 console.error(error);
19 // Handle the error
20 }
21}
22
23/* 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": false
44* "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": false
64* }
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';
4
5export const myListIndexesFunction = webMethod(Permissions.Anyone, async (dataCollectionId, options) => {
6 try {
7 const elevatedListIndexes = elevate(indexes.listIndexes);
8 const listIndexesResponse = await elevatedListIndexes(dataCollectionId, options);
9 console.log(`List of indexes for this collection: ${listIndexesResponse.indexes}`);
10
11 return listIndexesResponse;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16});
17
18/* Promise resolves to a list of indexes for the specified collection, with paging metadata:
19* {
20* "indexes": [
21* {
22* "caseInsensitive": true,
23* "fields": [
24* {
25* "order": "ASC"
26* "path": "itemName",
27* },
28* {
29* "order": "DESC"
30* "path": "size",
31* }
32* ],
33* "name": "byItemNameAndSize",
34* "status": "ACTIVE",
35* "unique": false,
36* },
37* {
38* "caseInsensitive": false
39* "fields": [
40* {
41* "order": "ASC"
42* "path": "size",
43* },
44* {
45* "order": "DESC"
46* "path": "available",
47* }
48* ],
49* "name": "bySizeAndAvailability",
50* "status": "ACTIVE",
51* "unique": false,
52* }
53* ],
54* "pagingMetadata": {
55* "count": 2,
56* "offset": 0,
57* "total": 2,
58* "tooManyToCount": false
59* }
60* }
61*/
62