请考虑以下的火力结构:
{
用户:{
00:03:AA:DC:1C:2B:{
名字:地平线,
组名:泰国,
姓氏:罗恩,
注册 : {
类型:普通,
时代:1418288589636
},
phoneNumber的:345345345
},
04:46:65:8D:60:C6:{
名字:地平线,
组名:泰国,
姓氏:罗恩,
注册 : {
类型:普通,
时代:1418288589630
},
phoneNumber的:345345345
},
}
}
你是怎么实现下面的查询:
SELECT * FROM用户它组名=泰国和registration.time> = 1418288589631
我试图做这样的:
fireBase.orderByChild("groupName").startAt("thailand").endAt("thailand").orderByChild("time").startAt("1418288589631")
但抛出一个异常,因为火力犯规让多个orderbys ...
任何想法?
解决方案火力地堡目前只支持每个查询单个排序依据
。
因此,如果您要筛选(或订单)的多个属性,你要么必须做额外的滤波(或排序)客户端在你的JavaScript code或你有来与它结合了性能你自己的索引方案。
Consider following firebase structure :
{
"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"
},
}
}
how do you implement the following query :
SELECT * FROM USERS WHERE groupName="thailand" and registration.time>=1418288589631
I was trying to do it like this :
fireBase.orderByChild("groupName").startAt("thailand").endAt("thailand").orderByChild("time").startAt("1418288589631")
but that threw an exception since firebase doesnt allow multiple orderbys...
Any ideas?
解决方案Firebase currently only supports a single orderBy
per query.
So if you want to filter (or order) on more than one property, you'll either have to do the additional filtering (or ordering) client-side in your JavaScript code or you'll have to come up with your own indexing scheme that combines the properties.