如何编写具有唯一ID的firebase规则
这就是我的问题:如何编写具有唯一ID的firebase规则,firebase,firebase-realtime-database,firebase-security,Firebase,Firebase Realtime Database,Firebase Security,这就是我的问题: WARN: FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "id_logement" at /images/-KNx2y3mAkJZ-Poa7R03 to your security rules for better performance 我不是firebase和规则方面的真正大师,所以这对我来说并不意味着什么。。。但我知道有个问题 这是我的数据结构: 这是我的规则 {
WARN: FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "id_logement" at /images/-KNx2y3mAkJZ-Poa7R03 to your security rules for better performance
我不是firebase和规则方面的真正大师,所以这对我来说并不意味着什么。。。但我知道有个问题这是我的数据结构:
这是我的规则
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"accounts" : {
".read": true,
".write": true,
".indexOn": ["userId", "email", "lat",]
},
"geofire" : {
".read": true,
".write": true,
".indexOn": ["g"]
},
"logements" : {
".read": true,
".write": true,
".indexOn": ["id_account"]
}
}
}
我想这是因为我不知道如何在规则中写入这个唯一的id!你能帮我吗?谢谢回答您的问题您希望在规则中使用的是表示分支键的通配符的
$id
符号
{
"rules": {
".read": "auth != null",
".write": "auth != null",
...
"images": {
"$imageId1": {
".indexOn": "id_logement"
}
}
}
}
但是,请记住,您不应该将imagesUrl
存储在两级深键中。使代码具有images/imageUniqueKey/imageData
结构,而不是images/imageUniqueKey1/imageUniqueKey2/imageData
。那么你的规则如下
"images": {
".indexOn": "id_logement"
}
谢谢@adolfosrs!!谢谢你的建议:)