I want to filter out the all questions where isValid flag is set to false, and want to retrieve in order of question count.
This is sample Data in firebase.
Question: {
Key1: {
text:"Text1",
isValid:true,
count:1
},
Key2:{
text:"Text2",
isValid:false,
count:2
},
Key3:{
text:"Text3",
isValid:true,
count:3
},
Key4:{
text:"Text4",
isValid:false,
count:4
},
Key5:{
text:"Text5",
isValid:true,
count:5
},
Key6:{
text:"Text6",
isValid:true,
count:6
}
...
},
User: {
Key1: {
name:"User1",
lastValue:1
},
Key2: {
name:"User2",
lastValue:3
}
}
User get 2 question daily and his lastValue is updated. I have tried below approach but its only giving the next two questions. I want to filter out the invalid question.
let QUESTION_PATH = "Question"
let LASTVALUE = 1
Database.database().reference().child(QUESTION_PATH).queryOrdered(byChild: "count").queryStarting(atValue: LASTVALUE).queryLimited(toFirst: 2).observeSingleEvent(of: .value, with: {(snapshot) in
//I want to Get the only next two valid question. in Above Example it should give 3 and 5. But this query will give 2 and 3.
})