请求关于云数据库表为空时 查询出错的问题?
发布于 6 年前 作者 jinxiulan 14192 次浏览 来自 官方Issues

我新建了一张表在云数据库,这时候还没有数据,然后,我在云函数进行id条件查询会报错。

正常不是null之类的吗?

难道每个查询之前都需要先查询表是否为空?

大概的报错如下:

Error: errCode: -1 unknown error | errMsg: document.get:fail document with _id 0709965b4f6c33f2c2cf859b12b231aa does not exist; at document.get api;
    at new CloudSDKError (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\wx-server-sdk\index.js:6360:28)
    at returnAsCloudSDKError (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\wx-server-sdk\index.js:6412:16)
    at Object.returnAsFinalCloudSDKError (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\wx-server-sdk\index.js:6426:13)
    at DocumentReference.<anonymous> (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\wx-server-sdk\index.js:1506:40)
    at step (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\tslib\tslib.js:136:27)
    at Object.next (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\tslib\tslib.js:117:57)
    at fulfilled (C:\Users\hasbu\code\oil_preference\cloudfunctions\getGasCollect\node_modules\tslib\tslib.js:107:62)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
2 回复

你还需要提供给我们这些情况下的运行结果:

1、表里有数据,但没有该_id;运行结果是什么?

2、表里有数据,且有_id的doc,运行结果是什么?

进行id查询如果没有找到对应的话也不会报错啊,你看看是不是其他地方出错了

回到顶部