The Firebase databases implement fairly limited query support. To expand that you often have to:
- Expand/modify your data model to allow the query you want
- Do part of your filtering in either client-side code, or in other systems (such as a dedicated full-text search engine).
There is no way to implement your conditions in a query on the Realtime Database, since:
- It only supports a single condition per query.
- It doesn’t support OR conditions.
You can sometimes combine multiple AND conditions into a single query, by adding a synthetic property to your data, such as "dates_serviceId": "..._..."
. With such a property in place, you can then query for ref.orderBy("dates_serviceId").equalTo("myDate_myServiceId")
.
To be able to query on nodes that have either lunch or dinner service, you’d have to expand your data model to explicitly identify such nodes, for example by adding a "lunch_or_dinner": true
property to them. With such a node, you can then query: ref.orderBy("lunch_or_dinner").equalTo(true)
By combining these two approaches, you could even create a single property for the entire query (dates_serviceId_lunch-or-dinner
), although I must admit that is becoming a bit overly specific even to my taste.
CLICK HERE to find out more related problems solutions.