Lets assume I have a List of String (ex: List<String>
). I want to match all the Strings in the List to a particular attribute already present in the Firebase Database. How do I achieve this, as the equalTo() query only accepts a single String. I also don't want to generate as many queries as the List size. Any help would be much appreciated.
Asked
Active
Viewed 807 times
0

Jason Bakthakumar
- 21
- 5
-
2Compared to SQL databases, the query capabilities of Firebase (and most other NoSQL solutions) are quite limited. There is no way to send a single query that returns items matching one of a number of strings. You may be able to use a range-query, but even that will only apply for a small subset of the use-cases. The good news is that multiple queries may not be that bad of an option, given that Firebase pipelines requests over a single connection. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 – Frank van Puffelen Dec 22 '16 at 16:31
-
@FrankvanPuffelen thanks for helping out..:) – Jason Bakthakumar Dec 23 '16 at 07:45
-
@FrankvanPuffelen But shouldn't a List size of 200 Strings (approx size) be a concern?? (Sending requests for all the 200 entries)... – Jason Bakthakumar Dec 23 '16 at 08:00
-
1You should only retrieve data that you display to the user. If you target devices that can display 200 strings and you app has a way to show them in a meaningful way, then you should retrieve 200 items. Performance wise, there is little difference between a single `getItems(1,2,3,...200)` and `getItem(1), getItem(2), getItem(3)...getItem(200)`. The link I provided explains why. – Frank van Puffelen Dec 23 '16 at 14:45
-
@FrankvanPuffelen Thanks a lot.. and Happy holidays...:) – Jason Bakthakumar Dec 23 '16 at 18:06