使用多个过滤器从Firebase查询数据 [英] Querying data from Firebase using multiple filters
问题描述
我有一个名为products
的Firebase数组,其中包含类似以下项:
I have a Firebase array called products
that contains items like this one:
JhMIecX5K47gt0VaoQN: {
brand: "Esprit"
category: "Clothes",
gender: "Boys",
name: "Pants",
}
是否可以使用带有Firebase API的多个过滤器从该阵列中查询产品.例如,我可能想按brand
和category
过滤(所有裤子"按"Esprit"过滤).到目前为止,我已经尝试通过子键进行排序,然后限制该排序的开始和结束,但是我不知道如何应用更多过滤器.
Is it possible to query products from this array using multiple filters with the Firebase API. For example I might want to filter by brand
and category
(all "Pants" by "Esprit"). So far I've tried ordering by child key and then limiting the start and end of this ordering, but I can't figure out how to apply more filters.
我正在使用iOS SDK.
I'm using the iOS SDK.
推荐答案
Firebase一次只能对一个属性(或值)进行排序/过滤.如果您在单个查询中多次调用orderBy...
方法,则会引发错误,表明不允许这样做.
Firebase can only order/filter on one property (or value) at a time. If you call a orderBy...
method multiple times in a single query it will raise an error to indicate this is not allowed.
这篇关于使用多个过滤器从Firebase查询数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!