新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)小程序教程:微信小程序云開發(fā) API數(shù)據(jù)庫·聚合
databaseAggregate
本接口應(yīng)在服務(wù)器端調(diào)用,詳細(xì)說明參見服務(wù)端API。
數(shù)據(jù)庫聚合
請求地址
POST https://api.weixin.qq.com/tcb/databaseaggregate?access_token=ACCESS_TOKEN
請求參數(shù)
| 屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 |
|---|---|---|---|---|
| access_token | string | 是 | 接口調(diào)用憑證 | |
| env | string | 是 | 云環(huán)境ID | |
| Query | string | 是 | 數(shù)據(jù)庫操作語句 |
返回值
Object
返回的 JSON 數(shù)據(jù)包
| 屬性 | 類型 | 說明 |
|---|---|---|
| errcode | number | 錯誤碼 |
| errmsg | string | 錯誤信息 |
| data | Array. | 記錄數(shù)組 |
errcode 的合法值
| 值 | 說明 | 最低版本 |
|---|---|---|
| 0 | 請求成功 | |
| -1 | 系統(tǒng)錯誤 | |
| -1000 | 系統(tǒng)錯誤 | |
| 40014 | AccessToken 不合法 | |
| 40097 | 請求參數(shù)錯誤 | |
| 40101 | 缺少必填參數(shù) | |
| 41001 | 缺少AccessToken | |
| 42001 | AccessToken過期 | |
| 43002 | HTTP METHOD 錯誤 | |
| 44002 | POST BODY 為空 | |
| 47001 | POST BODY 格式錯誤 | |
| 85088 | 該APP未開通云開發(fā) | |
| 其他錯誤碼 | 云開發(fā)錯誤碼 |
請求數(shù)據(jù)示例
{
"env":"test2-4a89da",
"query": "db.collection(\"test_collection\").aggregate().match({tags:\"cloud\"}).limit(10).end()"
}
返回數(shù)據(jù)示例
{
"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\":\"學(xué)習(xí) cloud database\"}",
"{\"_id\":\"51f4f67e-a6a1-4c3e-a50f-827380b8da86\",\"description\":\"學(xué)習(xí) 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\":\"學(xué)習(xí) cloud database\",\"due\":\"2019-09-09\"}"
]
}
數(shù)據(jù)庫操作語句說明
數(shù)據(jù)庫操作語句語法與數(shù)據(jù)庫 API相同, 聚合操作參考聚合文檔
文章標(biāo)題:創(chuàng)新互聯(lián)小程序教程:微信小程序云開發(fā) API數(shù)據(jù)庫·聚合
文章URL:http://www.dlmjj.cn/article/dpgossh.html


咨詢
建站咨詢

