w***@hotmail.com
w***@hotmail.com
  • 发布:2022-05-01 20:11
  • 更新:2022-05-02 15:44
  • 阅读:552

['.read']:get方法内参数值必须唯一位置

分类:uniCloud

数据库有如下get权限

 "permission": {  
    "read": "get(`database.yph-company.${doc.company_id}`).tagid in auth.role",  
    "create": true,  
    "update": "get(`database.yph-company.${doc.company_id}`).tagid in auth.role",  
    "delete": "get(`database.yph-company.${doc.company_id}`).tagid in auth.role"  
  } 

在自动生成的代码中加入where测试条件,可以成功,如下:

collectionList: [db.collection('yph-company-processing').where('company_id == "0067b443625d2724010c8ea55f480b73"').getTemp(), db.collection('yph-syscode').getTemp() ],

但admin用户查询所有确报错:['.read']:get方法内参数值必须唯一位置。
admin角色不是不受权限限制吗?

还有,数据库get权限下,doc(id)也是返回['.read']:get方法内参数值必须唯一位置错误,都必须在查询条件中加上company_id,如下是edit代码:

/**  
       * 提交表单  
       */  
      submitForm(value) {  
        // 使用 clientDB 提交数据  
        return db.collection(dbCollectionName).where('company_id=="'+this.formData.company_id+'" && _id=="'+this.formDataId+'"').update(value).then((res) => {  
          uni.showToast({  
            title: '修改成功'  
          })  
          this.getOpenerEventChannel().emit('refreshData')  
          setTimeout(() => uni.navigateBack(), 500)  
        })  
2022-05-01 20:11 负责人:无 分享
已邀请:
w***@hotmail.com

w***@hotmail.com (作者) - suman

是不是数据库get权限对admin也是有效的?

我把权限改为:
···
"read": "'admin' in auth.role || get(database.yph-company.${doc.company_id}).tagid in auth.role",
···

还是对admin有权限验证,好像没有这样写法!

有哪位大神能指点指点,如何让admin角色不受数据库get权限限制。

w***@hotmail.com

w***@hotmail.com (作者) - suman

数据库权限不能连表查询,如有两个表:
一个街道表district,设置"read": "doc.code in auth.role",街道code放入用户角色中
一个街道下的企业表company,含有街道编码district_code,设置表级权限"read": "doc.district_code in auth.role"

连表查询:

[db.collection('yph-company').where('district_code=="440606003000" || district_code=="440607402000"').getTemp(), db.collection('yph-district').getTemp()]

在非admin角色下,查不出数据!!!

w***@hotmail.com

w***@hotmail.com (作者) - suman

折腾了几天的数据库权限与unicloud-db组件之间的配合,基本这两个不可兼得,放弃了!

该问题目前已经被锁定, 无法添加新回复