Http调用数据库只能单个添加数据,不能使用数组批量添加
发布于 7 年前 作者 tianjie 12449 次浏览 来自 官方Issues

调用https://api.weixin.qq.com/tcb/databaseadd?access_token=xxxx时post参数为

{
    “env”:“yuanchengkongzhi-37zq0”,
    “query”: “db.collection(\“weixiubaobiao\”).add({ data: [{ _id: ‘123’},{ _id: ‘456’}] })”
}

添加多个数据会回复错误{

"errcode": -605101,    "errmsg": "RuntimeError: error while executing function add: Error: errCode: -401003 api parameter type error | errMsg: parameter.data should be object instead of array; (at line 1, col 31) hint: [Pws2BA07142162]" }

去掉数组只添加一个数据

{
    "env":"yuanchengkongzhi-37zq0",
    "query": "db.collection(\"weixiubaobiao\").add({ data: { _id: '123'}})"
}
回复正常

{
    "errcode": 0,
    "errmsg": "ok",
    "id_list": [
        "124"
    ]
}

不能把多个记录放到数组就不能一次提交多个数据了。

回到顶部