收藏
回答

到底如何才能根据数据库中的sharedUsers来判定查询权限。

框架类型 问题类型 终端类型 AppID 环境ID 基础库版本
小程序 Bug 微信iOS客户端 wxd5bd6c376fc089dc prdo-0g3t2x5wc94f9481 3.7.6

https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/guide/database/security-rules.html。

目前test数据库中自定义安全规则如下:

{
  "read": "auth.openid in get(`database.test.${doc._id}`).sharedUsers",
  "write": false,
}


为什么我的 sharedUser 中明明包括了当前用户的 openid 在查询test库中所有 sharedUsers中包括了当前用户的openid的记录时会一直提示:database permission denied。


查询命令如下:

    const result = await db
      .collection("test")
      .where({
        sharedUsers: openid,
       //  _openid: openid,
      }).get();


如果我把 read 设置为 true,则可以查询出来。


## 更新

发现即使设置为创建者都是没有权限的:

{
  "read": "doc._openid == auth.openid",
  "write": "doc._openid == auth.openid"
}


对此只想说mmp

最后一次编辑于  01-24
回答关注问题邀请回答
收藏
登录 后发表内容