# 数据库索引管理
接口应在服务器端调用,详细说明参见服务端API。
# 接口说明
# 接口英文名
dbindexManage
# 功能描述
该接口用于创建索引和删除索引
# 调用方式
# HTTPS 调用
POST https://api.weixin.qq.com/componenttcb/dbindex?access_token=ACCESS_TOKEN
# 创建索引
# 请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| access_token | string | 是 | 第三方接口调用令牌component_access_token | |
| action | string | 是 | create | |
| env | string | 是 | 环境ID | |
| collection_name | string | 是 | 集合名称 | |
| indexes | Array.<Object> | 是 | 索引信息 |
indexes 的结构
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| name | string | 是 | 索引名称 | |
| keys | Array.<Object> | 是 | keys信息 |
keys 的结构
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| name | string | 是 | 字段名 | |
| direction | string | 是 | 字段排序 |
direction 的合法值
| 值 | 说明 | 最低版本 |
|---|---|---|
| "1" | 升序 | |
| "-1" | 降序 | |
| "2dsphere" | 地理位置 |
# 返回值
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errcode | number | 错误码 |
| errmsg | string | 错误信息 |
# 删除索引
# 请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| access_token | string | 是 | 第三方接口调用令牌component_access_token | |
| action | string | 是 | delete | |
| env | string | 是 | 环境ID | |
| collection_name | string | 是 | 集合名称 | |
| indexes | Array.<Object> | 是 | 索引信息 |
indexes 的结构
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| name | string | 是 | 索引名 |
# 返回值
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errcode | number | 错误码 |
| errmsg | string | 错误信息 |
# 调用示例
示例说明: 创建索引
# 请求数据示例
{
"env": "mmtest-5g7z68c153d7ff4b",
"collection_name": "test",
"indexes": [
{
"name":"due_index",
"keys": [
{
"name": "due",
"direction": "1"
}
]
}
]
}
# 返回数据示例
{
"errcode": 0,
"errmsg": "ok",
}
示例说明: 删除索引
# 请求数据示例
{
"env": "mmtest-5g7z68c153d7ff4b",
"collection_name": "test",
"indexes": [
{
"name":"due_index"
}
]
}
# 返回数据示例
{
"errcode": 0,
"errmsg": "ok",
}
# 错误码
| 错误码 | 错误码取值 | 解决方案 |
|---|---|---|
| 0 | ok | ok |
| -1 | system error | 系统繁忙,此时请开发者稍候再试 |
| -1000 | system error | 系统错误 |
| 40014 | invalid access_token | 不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口 |
| 40097 | invalid args | 参数错误 |
| 40101 | missing parameter | 缺少必填参数 |
| 41001 | access_token missing | 缺少 access_token 参数 |
| 42001 | access_token expired | access_token 超时,请检查 access_token 的有效期,请参考基础支持 - 获取 access_token 中,对 access_token 的详细机制说明 |
| 43002 | require POST method | 需要 POST 请求 |
| 44002 | empty post data | POST 的数据包为空。post请求body参数不能为空。 |
| 47001 | data format error | 解析 JSON/XML 内容错误;post 数据中参数缺失;检查修正后重试。 |
| 85088 | no qbase privilege | 该APP未开通云开发 |