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
5/*
6 * Sample dataCollectionId value = 'Jackets'
7 *
8 * Sample options value = {
9 * limit: 5
10 * }
11*/
12
13export 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}`);
18
19 return listIndexesResponse;
20 } catch (error) {
21 console.error(error);
22 // Handle the error
23 }
24});
25
26/* 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": false
47* "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": false
67* }
68* }
69*/
70