Reputation: 2341
How can i query firebase if my query looks like this:
Select * from table where employment="teacher" or employment="programmer"
Upvotes: 0
Views: 1527
Reputation: 1137
Firebase database is graph based database which focused on finding optimum path for solution. It doesn't work like sql and supports queries like sql. Although you can perform various operations like queryOrderedByKey, queryOrderedByValue, queryOrderedByChild etc.
For a reference project using firebase database: https://github.com/rheyansh/RFirebaseMessaging
For more operations: https://firebase.google.com/docs/database/ios/lists-of-data
Upvotes: 0
Reputation: 80914
There is no like query in firebase realtime database. The following queries are the ones that you can use:
Method Usage
queryOrderedByKey Order results by child keys.
queryOrderedByValue Order results by child values.
queryOrderedByChild Order results by the value of a specified child key or nested child path.
https://firebase.google.com/docs/database/ios/lists-of-data#sort_data
To solve your problem, you can change your database to the following:
users
pushId
name : peter
employment : programmer
group : teachProg
pushId
name : john
employment : teacher
group : teachProg
And then use queryOrderByChild("group").queryEqualToValue("teachProg")
and you will be able to retrieve all users that are programmers or teachers
Upvotes: 2