In my database, I have two nodes set up:
users: {user1: {uid: 'user1', name: "John"}, user2: {uid: 'user2', name: "Mario"}}
homework: {user1: {homeworkAnswer: "Sample answer"}}
Some users may or may not have homework assigned to them.
The goal is to retrieve a complete list of all users along with their respective homework data in a single call and subscription. What approach would be most effective in achieving this?
Below is the expected format for the obtained list using the provided example:
[{uid: 'user1', name: "John", homework: {homeworkAnswer: "Sample answer"}}, {uid: 'user2', name: "Mario"}]
These are the observable references for users
and homework
:
let usersObservable = this.af.getObservable(`users/`);
let hwObservable = this.af.getObservable(`homework/`);