1) 问题:
云数据库中导入10万量级数据,没使用云存储和云函数的功能,发现靠前的数据可以正常访问,靠后的数据访问不到,是正常吗?
实测靠前的数据为前20个可正常访问,后面的数据当尝试访问时会报以下错误,请问一下,可能是什么原因?
VM656:1 Uncaught (in promise) thirdScriptError
Cannot read property 'serial_no' of undefined
TypeError: Cannot read property 'serial_no' of undefined
at _callee2$ (http://127.0.0.1:45388/appservice/pages/index/index.js:179:38)
at L (http://127.0.0.1:45388/appservice/@babel/runtime/regenerator.js:1:4935)
at Generator._invoke (http://127.0.0.1:45388/appservice/@babel/runtime/regenerator.js:1:4723)
at Generator.t.<computed> [as next] (http://127.0.0.1:45388/appservice/@babel/runtime/regenerator.js:1:5114)
at asyncGeneratorStep (http://127.0.0.1:45388/appservice/@babel/runtime/helpers/asyncToGenerator.js:1:624)
at c (http://127.0.0.1:45388/appservice/@babel/runtime/helpers/asyncToGenerator.js:1:842)
console.error @ VM656:1
errorReport @ VM662 WAService.js:2
thirdErrorReport @ VM662 WAService.js:2
(anonymous) @ VM662 WAService.js:2
s @ VM662 WAService.js:2
i @ VM662 WAService.js:2
(anonymous) @ VM662 WAService.js:2
value @ VM662 WAService.js:2
t @ VM662 WAService.js:2
(anonymous) @ VM662 WAService.js:2
2) 访问数据库的代码如下
const DB = wx.cloud.database().collection("checkInfo");
......
click: function () {
wx.scanCode({
success: async res => {
const {
result
} = res;
var serial_num = result.substring(0, 16);
serial_no = serial_num;
let res = await DB.get();
for (var a = 0; a < 1000000; a++) {
if (res.data[a].serial_no == serial_num) {
//查询次数+1
await DB.where({
serial_no: res.data[a].serial_no,
})
.update({
data: {
check_time: res.data[a].check_time + 1,
},
});
scan_times = res.data[a].check_time;
console.log("Internal checked scan_times is ", scan_times);
console.log(res);
break;
}
}
}
})
}
想请教一下,只能成功访问云数据库前20个数据并更新值,试图访问后面的值会报错,是因为没有用到云函数?还是其他什么原因?
3) 报错信息为:
