I want to get all threads where status is member
or owner
I know how to get for either one
reference.queryOrdered(byChild: "status").queryEqual(toValue: "owner")
Can anyone guide me how to make OR query call?
I want to get all threads where status is member
or owner
I know how to get for either one
reference.queryOrdered(byChild: "status").queryEqual(toValue: "owner")
Can anyone guide me how to make OR query call?
You can't do OR style queries in Firebase.
You can work around this by adding an additional field that is set whenever status
is member
or owner
, and then querying on that field instead.
There is no support for OR
or other multi-clause queries, so you'll have to find another approach.
The simplest mapping would be to have a separate observer for each status and then merge the results client side. Contrary to what many developers think, this scales quite well since Firebase pipelines the queries/responses over a single connection.
Alternatively, you might be able to do a range query queryStarting(atValue: "member").queryEnding(atValue: "status")
of there are no values in between.
Also see:
OR
across multiple properties)AND
across properties)