我有这样的结构:
conversations:
-439f6b3c0958:
-messages:...
-users:
-ccb756c0:
-userId: ccb756c0
...
我正在尝试通过对话/ {someid} /用户节点内的userId
查询对话
Firebase SDK给我这个警告,它对性能非常不利
Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "users/ccb756c0/userId"' at conversations to your security and Firebase Database rules for better performance
我添加了此规则,但不能解决问题
"conversations": {
"$conversationId":{
"users" :{
"$uid":{
"userId": {".indexOn": ".value"}
}
}
}
}
我也没有运气尝试过这个
"conversations": {
"$conversationId":{
"users" :{
"$uid":{
".indexOn": "userId"
}
}
}
}
我应该为谁编写此规则以匹配我正在使用的结构?
答案 0 :(得分:1)
您需要在运行查询的级别上定义索引。现在你的水平太低了。
所以应该是:
"conversations": {
"$conversationId":{
"users" :{
"userId": {".indexOn": ".value"}
}
}
}