I'm developing a React Native app and having a query doubts.
I need to return all groups (eg "group-id-01"), where the provided UID exists within members.
This code return all groups:
const memberGroup = firebase.database().ref('groups')
memberGroup.once('value')
.then((snapshot) => {
console.log('snapshot');
console.log(snapshot.val());
})
.catch((error) => {
console.log('Erro');
console.log(error);
});
Result I'm having:
"group-id-01"
"members"
"no-uid-provided":"Belem"
"oZlTzlbCTGaZfsrzyxqABlnxt2e2":"Julia"
"name":"Rolling Stones"
Result I want:
"group-id-01"
"members"
"oZlTzlbCTGaZfsrzyxqABlnxt2e2":"Julia"
"name":"Rolling Stones"
Whell...
I've tried some queries with .orderByChild and .equalTo, but the result is null.
const memberGroup = firebase.database().ref('groups')
.orderByChild('oZlTzlbCTGaZfsrzyxqABlnxt2e2')
.equalTo('Julia')
memberGroup.once('value')
.then((snapshot) => {
console.log('snapshot');
console.log(snapshot.val());
})
.catch((error) => {
console.log('Erro');
console.log(error);
});
I'm new in Firebase and I don't know if is possible to query a child inside another child with unknown name.
Appreciate all the help :D