https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/security-rules.html
{
"read": "auth.openid == 'oEQLf4rd8w2C85Ly3B8FxXXyz8RA' || doc._openid == auth.openid",
"create": true,
"update": "auth.openid == 'oEQLf4rd8w2C85Ly3B8FxXXyz8RA' || doc._openid == auth.openid",
"delete": "auth.openid == 'oEQLf4rd8w2C85Ly3B8FxXXyz8RA' || doc._openid == auth.openid"
}
指定openid = 'oEQLf4rd8w2C85Ly3B8FxXXyz8RA'的用户或者记录创建者可查看修改删除, 此时只有指定的用户可以查看信息, 创建者查看报错
Error: errCode: -502003 database permission denied | errMsg: Permission denied
at new s (VM1665 WAService.js:2)
at Function.success (VM1665 WAService.js:2)
at C (VM1665 WAService.js:2)
at Object.success (VM1665 WAService.js:2)
at Q (VM1665 WAService.js:2)
at d (VM1665 WAService.js:2)
at VM1665 WAService.js:2
at A.<anonymous> (VM1663 asdebug.js:1)
at C (VM1665 WAService.js:2)
at VM1665 WAService.js:2
是因为你没有在查询语句中填写 openid,
db.collection('xxx').where({_openid: 'xxxxxxxxxx'}).get()
比如权限是 {"read": "doc.key == '12321'"} ,就要求在查询语句里有key:'12321 ' ,即where({key:'12321'}),否则拒绝访问。
文档中有说明:
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/security-rules.html#%E7%AE%80%E4%BB%8B
经核实,请求的openid 确实不是你写的这个openid,还请自查。