Finding objects with multiple equalTo's

4,254 views
Skip to first unread message

Bryan

unread,
Dec 7, 2014, 11:04:04 PM12/7/14
to fireba...@googlegroups.com
Lets say I have:

{
   "$id": {
      "cateogry_id": 123,
      "name": "name_1"
   }
}

and I do: orderBy="category_id"&equalTo="123"

I know firebase doesn't allow doing multiple orderBy statements but what would be an appropriate work around if I needed to narrow down my search with 2 distinct values.

For example, if multiple $id's had the same category_id and I needed to find an item with a particular category_id and name? Is there a straight forward way to do this in firebase?

Jacob Wenger

unread,
Dec 8, 2014, 12:48:07 AM12/8/14
to fireba...@googlegroups.com
​Hey Bryan,

The current iteration of Firebase queries unfortunately do not provide an easy way to do this kind of operation. As you noted, you are limited to query on a single key. As a result, you will have to manually search through your filtered items to get further filter on that second key. The other suggestion I would give is to possibly restructure you data to make this query easier. I'm not sure if that's a possibility in your case, but it is often possible.

Jacob​

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e623407a-67e0-45ef-b7df-ad5dc8eef12c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bryan

unread,
Dec 9, 2014, 9:43:51 AM12/9/14
to fireba...@googlegroups.com
Thanks Jacob
Reply all
Reply to author
Forward
0 new messages