I am trying to get the child value of sender if its equal to the current logged in user.. but I was unable to get the same.
The JSON of the database is below:-
{
"requests" : {
"YJ5qTg2uuqQeicsWCTCNQMv4OwL2" : {
"-Lecn9gN5puugx5z-PKX" : {
"sender" : "0XWmi1Izr6XHYvqxamfNHDONSVA2",
"status" : "Pending"
}
}
}
}
This is what I have tried but I am always getting null.
this.firebase.database().ref('/requests').orderByChild('sender').equalTo(firebase.auth().currentUser.uid).on('value',(snapshot) =>
{
console.log(snapshot.val());
})
But every time I am getting null.
I did understand that I should provide the child address to reach to the grand child.
this.firebase.database().ref('/requests').orderByChild('-Lecn9gN5puugx5z-PKX/status').equalTo('Pending').on('value',(snapshot) =>
{
console.log(snapshot.val());
})
If I am explicitly providing the child address then I am getting the value needed.