我们在系统中有两个角色:管理者和用户,并希望允许管理者为用户读写数据。
我们为每个用户都有一个集合,保存该用户的报告对象。例如:
集合:用户/GUIDforTheUser/
在这个集合中,我们保留谁向谁报告(AccountId 代表 userId 的管理者)。
我们还有一个数据集合:data/GUIDforTheUser/,我想允许经理(报告)向向他报告的用户读取和写入数据。我该如何写规则?

We have 2 roles: manager and user in the system and want to allow manager to read and write data for the user.
We have a collection for each user where we keep to whom that user is reporting. For example:
collection: users/GUIDforTheUser/
In this collection, we keep who reports to whom (AccountId represents the mangager of the userId).
We also have a data collection: data/GUIDforTheUser/, and I want to allow manager(report) to read and write the data to the user who reports to him. How would I write the rule?


发布评论
评论(1)
您可以使用获取
/user/{userId}
文档,并在该文档中检查accountiD
是否匹配用户的UID,试图读取信息:You can use
get()
to fetch/user/{userId}
document and check ifaccountId
in that document matches UID of user trying to read the information: