【发布时间】:2020-12-28 01:33:09
【问题描述】:
JSON:
"people" : {
“user uid” : {
“**Domain** : "aol.com",
"peopleWhoLike: {
"-M-vZavBdcpX3SzkvgKN" : "**IrrBgFY9C1ekMmHUkQRzc5LhbDu1**", ////this is autokey: uid of the likeR///
}
}
假设您要评估 IrrBgFY9C1ekMmHUkQRzc5LhbDu1。如果他没有通过 childByAutoID 进行,我会使用这个:
,"peopleWhoLike" : {
"$peopleWhoLike_id": {
".read": "auth.uid != null",
".write": "$peopleWhoLike_id == auth.uid && data.parent().parent().child('domain').val() == data.parent().parent().parent().child(newData.val()).child('domain').val()"
} /////checks domain of like with domain of person he likes, and makes sure only he can write for himself.
如果 IrrBgFY9C1ekMmHUkQRzc5LhbDu1 没有 ChildByAutoID,这会很好,但事实并非如此。所以现在我想我需要使用 $ChildByAutoID 之类的东西,但我不知道该怎么称呼它,因为它没有在 JSON 中明确定义。
我为 $ 变量阅读的安全规则来源:https://firebase.google.com/docs/database/security/rules-conditions
【问题讨论】:
标签: json firebase-realtime-database firebase-authentication firebase-security