收藏
回答

自定义云数据库权限,错误代码-502003(无权限)?

//user表
{
"_openid":string//openid
"basicAdmin":true
}
//test表权限
{
"read": "doc._openid == auth.openid || get(`database.user.${auth.openid}`).basicAdmin==true",
"write": "get(`database.user.${auth.openid}`).basicAdmin==true"
}
//本地测试代码
test() {
    db.collection('test').add({
      data:{
        text:'123'
      }
    })
    .then(res => {
      console.log(res)
    })
  },
//控制台打印
VM3299 WAService.js:2 Unhandled promise rejection Error: errCode: -502003 database permission denied | errMsg: Permission denied
    at success (VM3299 WAService.js:2)
    at r.success (VM3299 WAService.js:2)
    at u (VM3299 WAService.js:2)
    at Object.success (VM3299 WAService.js:2)
    at a (VM3299 WAService.js:2)
    at VM3299 WAService.js:2
    at Mi (VM3299 WAService.js:2)
    at VM3299 WAService.js:2
    at VM15 asdebug.js:1
   at C (VM15 asdebug.js:1)(env: Windows,mp,1.05.2201240; lib: 2.23.2)

 问题出哪了求解?

回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2022-04-06
    对应的是_id  搞错了
    {
    "_id":string//openid
    "basicAdmin":true
    }
    
    2022-04-06
    有用 1
    回复 2
    • biubiubiu
      biubiubiu
      2022-04-06
      为什么是_id呀,迷糊了。求解求解
      2022-04-06
      回复
    • Mr.Zhao
      Mr.Zhao
      发表于移动端
      2022-04-07回复biubiubiu
      为啥不是?文档有例子,不要凭感觉
      2022-04-07
      回复
登录 后发表内容