I was having some troubles when trying to retrieve from Firebase. Basically my groups table as such:
In this case, under group ID -KpFibCHjJ1xpfLd07WJ, there is one account ID -KpFiX2L7ENt6EBgrB0S. By right there will be more than one account, I am still working on the data insert.
I tried to retrieve the list of unique push ID for accounts under certain group:
var accounts = [];
var query = firebase.database().ref('groups').orderByChild('address').equalTo('Blk 165');
query.once( 'value', data => {
data.forEach(userSnapshot => {
let groupData = userSnapshot.val();
console.log(groupData );
accounts.push(groupData .accounts);
for(var i = 0; i < accounts.length; i++){
console.log(accounts[i]);
}
});
});
However, what has printed out from for loop is:
Object {
"-KpFiX2L7ENt6EBgrB0S": true,
}
Any ideas on how to extract out the list of unique push ID (-KpFiX2L7ENt6EBgrB0S) under certain child and store them into a temporary array?