云函数调用数据库出错
发布于 5 年前 作者 qluo 9919 次浏览 来自 问答

云函数代码:

// 云函数入口文件

const cloud = require(‘wx-server-sdk’)

cloud.init()

//数据库接口

const db = cloud.database()

// 云函数入口函数

exports.main = async (event, context) => {

const re = await db.collection(‘XXXX’).where({

opid: event.userInfo.openId,

}).field({

mxm: true,

mqx: true,

mid: false,

_id: false

})

.get({

success: function (res) {

//

}

}),

return {

ysl: re.data

}

}

云端测试报错为:

{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“Unexpected token return”

}

})

请问是什么原因

如上红线部分,update时这样自加1是不成功的,必须要先查询后再加吗?

回到顶部