This API should be called on the server side and cannot be called directly on the client side (Mini Program, web page, APP, etc.). For details, please refer to API Call Guide.
API English Name: updateDatabaseIndex
This API is used to modify database indexes. If you encounter any issues while using it, please post in the Open Platform Service Provider Zone for discussion.
1. Call Method
HTTPS Call
POST https://api.weixin.qq.com/tcb/updateindex?access_token=ACCESS_TOKEN
Cloud Call
- This API does not support cloud call.
Third-party Call
-
This API supports third-party platforms on behalf of Merchant call.
-
The permission set ID of this API is: 49
-
After the service provider obtains one of the permission set authorizations, it can use authorizer_access_token to call on behalf of Merchant, for details please refer to Third-party Call documentation.
2. Request Parameters
Query Parameters Query String Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| access_token | string | Yes | API call credential, you can use authorizer_access_token |
Request Body Request Payload
| Parameter | Type | Required | Description |
|---|---|---|---|
| env | string | Yes | Cloud environment ID |
| collection_name | string | Yes | Collection name |
| create_indexes | objarray | Yes | New index |
| drop_indexes | objarray | Yes | Index to delete |
Body.create_indexes(Array) Object Payload
New index
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Index name |
| unique | boolean | Yes | Is unique |
| keys | objarray | Yes | Indexed fields |
Body.drop_indexes(Array) Object Payload
Index to delete
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Index name |
| unique | boolean | Yes | Is unique |
| keys | objarray | Yes | Indexed fields |
Body.create_indexes(Array).keys<Array> Object Payload
Indexed fields
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Field name |
| direction | string | Yes | Field order |
Body.drop_indexes(Array).keys<Array> Object Payload
Indexed fields
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Field name |
| direction | string | Yes | Field order |
3. Response Parameters
Response Body Response Payload
| Parameter | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
4. Notes
No special notes for this API
5. Code Example
Request Example
{
"env": "test2-4a89da",
"collection_name": "counters",
"create_indexes": [
{
"name": "add_index",
"unique": true,
"keys": [
{
"name": "test",
"direction": "2dsphere"
}
]
}
],
"drop_indexes": [
{
"name": "del_index"
}
]
}
Response Example
{
"errcode": 0,
"errmsg": "ok",
}
6. Error Codes
The following is the error code list of this API, other error codes can refer to Common Error Codes; When encountering errors in calling the API, you can use the official API Diagnostic Tool to assist in locating and analyzing problems.
| Error Code | Error Description | Solution |
|---|---|---|
| -1000 | system error | System error |
| -1 | system error | The system is busy. Please try again later. |
| 0 | ok | ok |
| 40001 | invalid credential access_token isinvalid or not latest | The AppSecret is incorrect when obtaining access_token, or the access_token is invalid. Please verify the correctness of the AppSecret, or ensure the API is being called for the correct Official Account. |
| 40014 | invalid access_token | Invalid access_token. Please verify the validity of the access_token (e.g., check if it has expired), or ensure the API is being called for the correct Official Account. |
| 40097 | invalid args | Invalid parameters |
| 40101 | missing parameter | Required parameters are missing |
| 41001 | access_token missing | The access_token parameter is missing |
| 42001 | access_token expired | The access_token has expired. Please check the validity period of the access_token. Refer to the detailed mechanism description for access_token in Basic Support - Obtaining access_token. |
| 43002 | require POST method | A POST request is required |
| 44002 | empty post data | The POST request body is empty |
| 47001 | data format error | Failed to parse JSON/XML content; parameters are missing in the POST data. Please check, fix, and retry. |
| 85088 | no qbase privilege | Cloud Development is not enabled for this App. |
7. Applicable Scope
This API supports 「Third-party Platform」 account type for proxy calls. For permission sets, please refer to the "Call Method" section. Other account types cannot call unless otherwise specified.