Reputation: 340
This is my database schema as you can see value "iCgvaKOFlncNtHtjwUpC759PHTX2" under users_relations->userID->pending->uid
I am building query like this
let userRelationsPendingRef = Database.database().reference().child("users_relations").child("QvKH90udoIU9C3lbjP9OjpA5DC22").child("pending")
userRelationsPendingRef.queryEqual(toValue: "iCgvaKOFlncNtHtjwUpC759PHTX2").observeSingleEvent(of: .value, with: { (snapShot) in
if snapShot.exists() {
completion(.pending)
}
})
But it returns null in snapShot object. Any kind of help will be hight appreciated. Thanks
Upvotes: 0
Views: 152
Reputation: 3033
As was stated in the comments, make sure your path is correct, and then querying should be fine. In the original post you never added the "uid", so the correct code would be the following:
let userRelationsPendingRef = Database.database().reference().child("users_relations").child("QvKH90udoIU9C3lbjP9OjpA5DC22").child("pending")
userRelationsPendingRef.child("uid").queryEqual(toValue: "iCgvaKOFlncNtHtjwUpC759PHTX2").observeSingleEvent(of: .value, with: { (snapShot) in
if snapShot.exists() {
completion(.pending)
}
})
Upvotes: 1