# 数据库聚合

调试工具

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

# 接口说明

# 接口英文名

dbAggregate

# 功能描述

通过本接口可以数据库聚合,使用过程中如遇到问题,可在开放平台服务商专区发帖交流。

# 注意事项

  • 数据库操作语句说明:数据库操作语句语法与数据库 API相同, 聚合操作参考聚合文档

# 调用方式

# HTTPS 调用


POST https://api.weixin.qq.com/componenttcb/dbaggregate?access_token=ACCESS_TOKEN 

# 请求参数

属性 类型 必填 说明
access_token string 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用component_access_token
env string 云环境ID
query string 数据库操作语句

# 返回参数

属性 类型 说明
errcode number 错误码
errmsg string 错误信息
data array<string> 记录数组

# 调用示例

示例说明: HTTPS请求

# 请求数据示例


{
  "env":"test2-4a89da",
  "query": "db.collection(\"test_collection\").aggregate().match({tags:\"cloud\"}).limit(10).end()"
} 

# 返回数据示例


{
    "errcode": 0,
    "errmsg": "ok",
    "data": [
    "{\"_id\":\"f77e039f-f1cf-4aa8-bd59-16cbaa91e6ea\",\"location\":{\"type\":\"Point\",\"coordinates\":[{\"$numberDouble\":\"113.0\"},{\"$numberDouble\":\"23.0\"}]},\"done\":false,\"description\":\"learn cloud database\",\"due\":\"2019-09-09\",\"tags\":[\"cloud\",\"database\"]}",
        "{\"_id\":\"6bb88938-49ea-42b6-a6f5-ce408970cfc6\",\"due\":\"2019-09-09\",\"tags\":[\"cloud\",\"database\"],\"location\":{\"type\":\"Point\",\"coordinates\":[{\"$numberDouble\":\"113.0\"},{\"$numberDouble\":\"23.0\"}]},\"done\":false,\"description\":\"学习 cloud database\"}",
        "{\"_id\":\"51f4f67e-a6a1-4c3e-a50f-827380b8da86\",\"description\":\"学习 cloud database\",\"due\":\"2019-09-09\",\"tags\":[\"cloud\",\"database\"],\"location\":{\"coordinates\":[{\"$numberDouble\":\"113.0\"},{\"$numberDouble\":\"23.0\"}],\"type\":\"Point\"},\"done\":false}",
        "{\"_id\":\"ee1d69da-b7ec-4e7a-bc1f-2fae31da4ce0\",\"tags\":[\"cloud\",\"database\"],\"location\":{\"type\":\"Point\",\"coordinates\":[{\"$numberDouble\":\"113.0\"},{\"$numberDouble\":\"23.0\"}]},\"done\":false,\"description\":\"学习 cloud database\",\"due\":\"2019-09-09\"}"
    ]
} 

# 错误码

错误码 错误码取值 解决方案
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 的数据包为空
47001 data format error 解析 JSON/XML 内容错误;post 数据中参数缺失;检查修正后重试。
85088 no qbase privilege 该APP未开通云开发