Firebase IndexOn警告消息 [英] Firebase IndexOn Warning Message
问题描述
merchants {
merchantID1:{
merchantName:
branches :{
branchID1:{
branchAddress:
}
}
}
}
$ b 我在firebase网站的索引规则:
merchants:{
.indexOn:[merchantName]
},
I从JavaScript获得了两个不同的orderByChild查询。一个是查询 merchantName
,另一个是 branchAddress
。在firebase中添加 indexOn merchantName规则
后,警告消息消失。然而,当我执行另一个查询 branchAddress
的函数时,我得到这个警告信息:
pre > FIREBASE警告:使用未指定的索引。考虑在/ merchants / -KpeV5_lnWA2Zd_g7x8C /分支处添加.indexOn:
branchAddress到您的安全性
规则以获得更好的性能
我怎样才能真正指定indexOn规则在不同级别的子级?
$ childKey
匹配任何子键。所以你必须在这里使用这个概念。
$ b $ p更改你的分贝规则:
pre $ merchants:{
.indexOn:[merchantName],
$ merchantId:{/ *匹配所有键* /
branches: {
.indexOn:[branchAddress]
}
}
}
I have some question regarding the indexing of firebase. Here is my firebase structure:
merchants {
merchantID1 : {
merchantName :
branches : {
branchID1 : {
branchAddress :
}
}
}
}
My indexing rule at firebase site:
"merchants": {
".indexOn": ["merchantName"]
},
I got two different orderByChild query from JavaScript. One is querying merchantName
, the other is branchAddress
. After I added in the indexOn merchantName rule
at firebase, the warning message disappeared. However, when I perform another function which is querying the branchAddress
, I am getting this warning message:
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn":
"branchAddress" at /merchants/-KpeV5_lnWA2Zd_g7x8C/branches to your security
rules for better performance
How can I actually specify the indexOn rule at different level of a child?
$childKey
matches any child key. So you have to use that concept here.
Change your db rule to:
"merchants": {
".indexOn": ["merchantName"],
"$merchantId": {/*This matches all keys*/
"branches": {
".indexOn": ["branchAddress"]
}
}
}
这篇关于Firebase IndexOn警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!