考虑以下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"
},
}
}
Run Code Online (Sandbox Code Playgroud)
你如何实现以下查询:
SELECT * FROM USERS WHERE groupName="thailand" and registration.time>=1418288589631
Run Code Online (Sandbox Code Playgroud)
我试图像这样做:
fireBase.orderByChild("groupName").startAt("thailand").endAt("thailand").orderByChild("time").startAt("1418288589631")
Run Code Online (Sandbox Code Playgroud)
但由于firebase不允许多个订单,因此引发了异常......
有任何想法吗?
我需要最佳实践技巧,以增强我的noSQL数据库(在Firebase上托管)的性能。此外,我需要有关如何构造节点的技巧。
该数据库存储产品信息,具有三个主要属性:
$productId
/date
/category
/subcategory
Run Code Online (Sandbox Code Playgroud)
在我的网站上,我有三种看法:
请注意,我还有一个节点product_images,其子节点与productID匹配。因此,按以下方式构造数据库:
$categoryId
$subCategoryId
$productId
Run Code Online (Sandbox Code Playgroud)
无法使用,因为我需要事先知道$ categoryId和$ subCatrgoryId,然后才能将其与$ productId匹配。这也将使检索最后4个产品变得困难。
我将如何高效地构建noSQL数据库,以及如何使用Firebase筛选出具有多个限制的产品来检索产品?
我知道在Firebase中可以使用orderByChild和equalTo,但这仅适用于一个限制,而我必须处理一到三个。