is it possible to queryOrdered 2 times with Firebase? I first want to put the post on top with the most points and then I want to filter their age just like I did. If I run this I get an "Thread 1: signal SIGABRT "Error. How can i fix this?
func observeAllAgePosts(completion: @escaping (Post) -> Void) {
REF_POSTS.queryOrdered(byChild: "points").queryStarting(atValue: 0)
.queryEnding(atValue: 100000).queryOrdered(byChild: "Age").queryStarting(atValue: Age11)
.queryEnding(atValue: Age22).observeSingleEvent(of: .value, with: {
snapshot in
if snapshot.hasChildren(){
let arraySnapshot = (snapshot.children.allObjects as! [DataSnapshot]).reversed()
arraySnapshot.forEach({ (child) in
if let dict = child.value as? [String: Any] {
let post = Post.transformPostPhoto(dict: dict, key: child.key)
completion(post)
}
})
}else{
ProgressHUD.dismiss()
}
})
}
My structure: