如果STREET_ID
的ID为“-K1234567”,则允许STREET_ADDRESS
的写访问权
Firebase规则json:
{
"rules": {
"$countries": {
"STREET_ID": {
".read": "auth != null",
"$PathKey": {
".write": "root.child('US/STREET_ADDRESS').hasChild(-K1234567)",
".validate": "newData.isString()"
}
},
"STREET_ADDRESS": {
".read": "auth != null",
".write": "!data.exists()"
},
}
}
Firebase json:
"UA": {
"name": "Ukraine"
},
"AE": {
"name": "United Arab Emirates"
},
"GB": {
"name": "United Kingdom",
"STREET_ID": {......
},
"US": {
"name": "United States",
"STREET_ID": {
"US/California/Orange County/Orange/3138 E Maple Ave": "-K1234567",
"US/California/Orange County/Orange/3139 E Maple Ave": "-K12334rt"
},
"STREET_ADDRESS": {
"-K1234567": {
"path": "US/California/Orange County/Orange/3138 E Maple Ave",
"values": {
"call": false,
"id": "",
"start_date": "",
"end_date": "",
"type": "",
"name": ""
}
},
.............
},
如您所见,“ - K1234567”是STREET_ADDRESS
中的推送键和STREET_ID
中的值,基本上用户只能在{{{}} STREET_ID
中插入STREET_ADDRESS
1}}。
我读到newData并试着像这样应用它:
".write": "root.child('US/STREET_ADDRESS').hasChild(newData.val())",
那不行或应该吗? 我怎样才能做到这一点?