我正在尝试查询一些看似无法正常通话的数据。
以下是数据的示例:
{
"currentSelectedPlayers" : {
"player1" : {
"assists" : "97",
"currentlyPickedBy" : {
"userID" : "641aada9-2d42-4b83-9883-ca316c842a08"
},
"goals" : "2",
}
}
在我的规则中,我设定了:
"rules": {
"$currentSelectedPlayers": {
".indexOn": ["currentlyPickedBy", ".value"]
}
}
我的查询:https://{database-address}.firebaseio.com/currentSelectedPlayers.json?orderBy="$value"&equalTo="641aada9-2d42-4b83-9883-ca316c842a08"&print=pretty
我知道firebase最近引入了对深层嵌套数据的查询。我如何正确查询此嵌套数据?
答案 0 :(得分:2)
您不需要.value
索引,而是路径``:
{
"currentSelectedPlayers": {
".indexOn": ["currentlyPickedBy/userID"]
}
}
然后您可以使用以下方式查询:
currentSelectedPlayers.json?orderBy="currentlyPickedBy/userID"&equalTo="641aada9-2d42-4b83-9883-ca316c842a08"&print=pretty