I am currently working on crafting a query for a denormalized database. Drawing inspiration from the example showcased in Firebase's blog post, my objective is to:
Retrieve the array of forms associated with the current user and return references to each individual item within that list.
Below is the snippet of code I have been developing:
getFormList():firebase.database.Reference {
// the old method
//return firebase.database().ref('/formsByID').orderByChild('userList').startAt(this.userId).endAt(this.userId);
var formRef = firebase.database().ref("/formsByID");
var userRef = firebase.database().ref("/userProfiles");
// this will be our list of forms beneath the user node
var userFormRef = userRef.child(this.userId).child("formsList");
// whenever an item is added to the forms list
userFormRef.on("child_added", function(snap) {
// snap.key represents the key of the form fetched from the forms list
//let formKey = snap.key(): string;
return formRef.child(snap.key);
});
}
The issue I'm encountering lies in typescript's expectation for my getFormList method to return a value, but a value will only be returned when a new item is appended to userFormRef - any assistance would be greatly appreciated.