I have a firebase datbase set up as follows: https://ibb.co/h8nQPZY
I want to retrieve a list of uids of all the groups that the given user uid appears in. For example, if I pass 'SnGXDFilErWEqFxPgWY5bIIAnPA3'
, it should return an array containing '-LstfBZj3hKDxpf8QxpT'
, as well as any other groups that user is in.
Here is what I have right now, although I've tried a few different things and it seems illogical:
async listGroups(userUid) {
let groups = [];
await firebase.database().ref('groups').orderByChild('members').equalTo(userUid).on('value', snap => {
snap.forEach(data => {
groups.push(data.key);
});
});
return groups;
}
Any help would be appreciated.