My database structure resembles the following:
https://i.sstatic.net/duWdk.png
/*
formsById
formId
usersList
userId
*/
I am trying to retrieve a list of all users (usersList) associated with a specific formId. Below is my method implementation in the provider:
// method to get a reference of users for a specific form
getFormsUsersRef(formId): firebase.database.Reference {
let formsRef = firebase.database().ref("formsById");
return formsRef.child(formId).child("usersList");
}
Here is the code snippet from my component:
// display the list of forms
ionViewDidLoad() {
this.sharingProvider.getFormsUsersRef(this.formId).on('child_added', fuSnap => {
// not getting any data
console.log(fuSnap);
});
}
Although the getFormsUsersRef method returns the correct database reference, the .on('child_added') event is not returning any data.
This methodology works flawlessly for another dataset in my app where the userIds are stored as Firebase uid values instead of push keys.
Any assistance would be greatly appreciated, as I have been struggling with this issue for hours now.