更新索引

updateIndex

本接口应在服务器端调用,详细说明参见服务端API

变更数据库索引

请求地址

POST https://api.weixin.qq.com/tcb/updateindex?access_token=ACCESS_TOKEN

请求参数

属性 类型 默认值 必填 说明
access_token / cloudbase_access_token string 接口调用凭证
env string 云环境ID
collection_name string 集合名称
create_indexes Array. 新增索引
drop_indexes Array. 删除索引

create_indexes 的结构

属性 类型 默认值 必填 说明
name string 索引名
unique boolean 是否唯一
keys Array. 索引字段

keys 的结构

属性 类型 默认值 必填 说明
name string 字段名
direction string 字段排序

direction 的合法值

说明 最低版本
"1" 升序
"-1" 降序
"2dsphere" 地理位置

drop_indexes 的结构

属性 类型 默认值 必填 说明
name string 索引名

返回值

Object

返回的 JSON 数据包

属性 类型 说明
errcode number 错误码
errmsg string 错误信息

errcode 的合法值

说明 最低版本
0 请求成功
-1 系统错误
-1000 系统错误
40014 AccessToken 不合法
40097 请求参数错误
40101 缺少必填参数
41001 缺少AccessToken
42001 AccessToken过期
43002 HTTP METHOD 错误
44002 POST BODY 为空
47001 POST BODY 格式错误
85088 该APP未开通云开发
其他错误码 云开发错误码

请求数据示例

{
  "env": "test2-4a89da",
  "collection_name": "counters",
  "create_indexes": [
    {
      "name":"add_index",
      "unique": true,
      "keys": [
        {
          "name": "test",
          "direction": "2dsphere"
        }
        ]
    }
    ],
  "drop_indexes": [
    {
      "name":"del_index"
    }
    ]
}

返回数据示例

{
    "errcode": 0,
    "errmsg": "ok",
}
posted on 2025-02-17 17:40  AtlasLapetos  阅读(5)  评论(0)    收藏  举报