在该函数中,输出的ID值是正确的
但是将ID赋值给wx.cloud.callFunction中的id时,则会报错,并且该id和上面的ID值不同。
代码及错误如下:
已经解决了,在云函数的更新数据里面,添加一个id: event.id就可以了
exports.main = async (event, context) => {
return await cloud.database().collection("classification1").doc(event.id)
.update({
data: {
id: event.id,
shoucang: event.shoucang
}
})
.then(res => {
console.log("改变收藏状态成功", res)
return res
})
.catch(res => {
console.log("改变收藏状态失败", res)
return res
})