请问云函数中调用数据库查询加插入为什么一直报错?谢谢
- 当前 Bug 的表现(可附上截图) [图片] 在云开发控制台测试云函数时,错误提示如下: 测试结果:失败返回结果: {"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Unexpected identifier"} 摘要 请求ID:4e47e746-1429-11e9-8070-525400770114 运行时间:2.581ms 计费时间:100ms 运行内存:0.125MB 日志 START RequestId: 4e47e746-1429-11e9-8070-525400770114 Event RequestId: 4e47e746-1429-11e9-8070-525400770114Event:{ "key1": "test value 1", "key2": "test value 2", "userInfo": { "appId": "wx87c393a34109b2b2", "openId": "oaoLb4qz0R8STBj6ipGlHkfNCO2Q" } } END RequestId: 4e47e746-1429-11e9-8070-525400770114 Report RequestId: 4e47e746-1429-11e9-8070-525400770114 Duration:2.581ms Memory:256MB MaxMemoryUsed:0.125MB - 复现路径 调用云函数时出错 - 提供代码片段 [代码]// 云函数入口文件[代码][代码]const cloud = require([代码][代码]'wx-server-sdk'[代码][代码])[代码] [代码]cloud.init()[代码][代码]const db = cloud.database()[代码] [代码]// 云函数入口函数[代码][代码]exports.main = async (event, context) => {[代码][代码] [代码][代码]var[代码] [代码]table_name = event.table_name[代码][代码] [代码] [代码] [代码][代码]try[代码] [代码]{[代码][代码] [代码][代码]var[代码] [代码]isExisted = [代码][代码]false[代码][代码] [代码][代码]if[代码][代码](table_name == [代码][代码]"bookinfo"[代码][代码]) {[代码][代码] [代码][代码]db.collection(table_name).where({[代码][代码] [代码][代码]isbn: event.isbn[代码][代码] [代码][代码]}).get({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]if[代码][代码](res.data.length == 0) {[代码][代码] return await [代码][代码]db.collection(table_name).add({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]isbn: event.isbn,[代码][代码] [代码][代码]title: event.title,[代码][代码] [代码][代码]author: event.author[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}) [代码][代码] [代码][代码]}[代码][代码] [代码][代码]} [代码][代码]catch[代码] [代码](e) {[代码][代码] [代码][代码]console.error(e)[代码][代码] [代码][代码]}[代码][代码]}[代码]