I have two nodes in my database - one which is allUsers
and one which is usersChildren
.
For example:
allUsers: { user1: {...}, user2: {...}}
usersChildren: { user1: {...} }
In this case user1
has children data and user2
does not.
I want to retrieve a list of all user objects, and inside each user's object I wish to add the children data from the usersChildren
node(if there is one).
However, I am not really familiar with how I can do that. I have tried the following but this results in obtaining only the children information and not a combined object with both the children information and the user meta data.
this.af.getObservable(`allUsers`).pipe(map(allUsers =>
allUsers.map(user => this.af.getObservable(`usersChildren/${user.id}`)))
.subscribe(allUsersData => this.userList = allUsersData);
What is the best way to achieve what I desire?