代码如下
const db = wx.cloud.database()
db.collection('articles').doc(that.data.collectID).update({
data: {
focus: true
},
success: function(res) {
console.log('res:', res)
wx.hideLoading()
that.succMsgTip()
},
fail: function(err) {
// console.log('err:', err)
wx.hideLoading()
that.errMsgTip()
}
})
首先我使用get()是可以正确获取到对应ID的内容
db.collection('articles').doc(that.data.collectID).get().then(res => { console.log('get res:', res)})
此时查看 focus 再数据库中的类型为boolean 当前值为 false
然后我打印返回也是OK的
errMsg: "document.update:ok"
stats: {updated: 0}
提示成功后 刷新数据库查看并没有修改focus的值为true
所以这是哪里不对吗 ?
上面给出了update: 0 但是没具体提示了 , 一头雾水
终于知道为什么了, 因为集合设置权限问题 , 使用自定义权限 读写都放开就OK了。。。