I have a "room" in my database that looks like this
room
-KJe22sduQMz1DIs_DH6
allowedParticipants:
14
createdBy:
"Mr Tester"
members:
"nmeMYnnSatRch5qKPJKIe7jEOLy2"
participating:
true
status:
"seedling"
theme:
"Cats"
totalNumberOfMembers:
1
I want to first sort by the theme which is cats in this particular room, but i dont want to show the room in the tableview if the totalNumberOfMembers is equal to allowedParticipants or if the status is anything but "open"...if it is seedling, or inProgress, or closed then i dont even want it to show up on the tableview
All i want on the tableview is open rooms
I think I found the right rule but it says
Queries can only order by one key at a time. Calling orderByChild() multiple times on the same query throws an error.
Is this the right rule or am i in the wrong place? Thank you
Edit
Since Firebase doesn't support what I want to do I am trying to follow the example provided in the comment
I am having issues thinking of how it will be written. If the data structure remains as it is, and i try to follow this code snippet
var ref = new Firebase('https://your.firebaseio.com/');
ref
.orderBy('genre')
.startAt('comedy').endAt('comedy')
.on('value', function(snapshot) {
var movie = snapshot.val();
if (movie.lead == 'Jack Nicholson') {
console.log(movie);
}
});
This is where I am getting stuck mentally
ref.queryOrderedByChild("status").queryStartingAtValue ....
Maybe I am just misunderstanding the rule but the value would be a different child right? Thank you.
Edit 2
I have tried this to no avail..
createdRoomRefGlobal.queryOrderedByChild("status").queryStartingAtValue("active").queryEndingAtValue("active").observeEventType(.Value) { (snapshot: FIRDataSnapshot) in
let themeOfEvent = snapshot.value
if themeOfEvent?.value == pickedTheme {
print("foo")
}
}
Nothing happens so I put in breakpoints and it hits it but does nothing. I must have an issue in how i've written it...