【发布时间】:2015-02-10 11:29:21
【问题描述】:
考虑以下 Firebase 结构:
{
"users" : {
"00:03:aa:dc:1c:2b" : {
"firstName" : " Ofek",
"groupName" : "thailand",
"lastName" : "Ron",
"registration" : {
"type" : "regular",
"time" : 1418288589636
},
"phoneNumber" : "345345345"
},
"04:46:65:8D:60:C6" : {
"firstName" : " Ofek",
"groupName" : "thailand",
"lastName" : "Ron",
"registration" : {
"type" : "regular",
"time" : 1418288589630
},
"phoneNumber" : "345345345"
},
}
}
你如何实现以下查询:
SELECT * FROM USERS WHERE groupName="thailand" and registration.time>=1418288589631
我试图这样做:
fireBase.orderByChild("groupName").startAt("thailand").endAt("thailand").orderByChild("time").startAt("1418288589631")
但这引发了异常,因为 firebase 不允许多个 orderbys...
有什么想法吗?
【问题讨论】:
-
Firebase 目前仅支持每个查询使用一个
orderBy。因此,如果您想过滤更多属性,则必须在 JavaScript 代码中执行额外的过滤客户端,或者您必须提出自己的索引方案来组合属性。 -
这应该是弗兰克的答案!