Here's the structure of the current database, unfortunately reordering is not an option.
I need to get all the items under the particular user, (5ef124...) but I don't have the uid (5ef124...). I do however have everything marked in green, and I see that the uid is saved under each key. Another issue is that not all records are complete like the one below. There are some that are empty, as in only the parent level key is there.
I have tried to replicate these answers but it's I'm not getting anything back (I'm not getting errors, just no data).
Firebase search by child value? #265
Firebase: Get the parent of a snapshot.
Here's what my broken code looks like, based on link #1:
$rootScope.secondFirebase.refs.vms = $rootScope.secondFirebase.db
.ref('/users')
.orderByChild('targetId')
.equalTo('somehardcodedtargetid')
.on('value', function(snapshot) {
//snapshot would have list of NODES that satisfies the condition
console.log(snapshot.val());
console.log('-----------');
//go through each item found and print out the emails
snapshot.forEach(function(childSnapshot) {
var key = childSnapshot.key;
var childData = childSnapshot.val();
//this will be the actual data value found
console.log(childData);
});
});
Thank you in advance for taking the time to help out.
Edit: please note in the screenshot, only 1 level is unknown. The db/users/5ef124... is the expanded key. It's not db/users/5ef124.../5ef124, but rather db/users/5ef124.../known key.. Or in other words: db/users/[unknown]/[known]. I hope this clarifies it a bit.