How can I make a Query in Firebase database to get some of the children in my console? For example, from the snapshot below, how can I make a query to get just the Image
s where Des: 11
.
I'm using this code:
func loadData(){
Ref=FIRDatabase.database().reference().child("Posts")
Handle = Ref?.queryOrdered(byChild: "11").observe(.childAdded ,with: { (snapshot) in
if let post = snapshot.value as? [String : AnyObject] {
let img = Posts()
img.setValuesForKeys(post)
self.myarray.append(img)
self.tableView.reloadData()
}
})
}
As El Capitain said, you'll need to use this:
Also, as he mentioned, you'll want to set your security rules to allow you to search by 'Des', or whatever other child node you'll be querying by. In addition, you'll need to set the rules to allow you read access to the query location:
However, you're not going to get 'only the images' though, your query will return the entire node. In this case, the query above would return the rrrrrr node.