I recently asked how to filter products based on their child property (see: Filter products based on a child child in Firebase ).
As an example, my structure is as follows:
products/ product1 /author: 12345 /title: "Awesome" /category: "catA" /description: "more awesome" product2 /author: 67890 /title: "Other" /category: "catB" /description: "otherawesome" product3 /author: 12345 /title: "Billy" /category: "catB" /description: "otherawesome"
And to filter out all products using the author of 12345 , we can simply use:
ref.child("products").orderByChild('author').equalTo(12345)...
However, what should I do when I have several AND statements or several OR statements?
So what if I want to filter:
In the first part I tried:
ref.child("products").orderByChild('author').equalTo(12345).orderByChild('category').equalTo('catA')...
but this did not work (throws an error You can't combine multiple orderBy calls )
See also: https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries
source share