What’s up guys, Eze is here. I already did couple of posts about Firebase and how to use the Real-Time database and the storage with AngularJs in case you missed it you can check here. Today I want to give you more details on how to do an advance query to join two references.
Let’s suppose we have the schema below and we want to retrieve the list of orders.
To do that we just need to do as we did several times in our previous examples and attach to the child_added event as I did in the code below. As you can see we get the data under the path orders, but we still need to show the data under the path users which is linked to our orders.
In the code below we now changed the query in order to get as well the user data from the path users. It’s important to highlight that this time I’m using the method once which will retrieve the data once and this data it’s not going to be live data, we are not going to receive notification if this data changes. There is another way to get the data in real time but we need to keep the reference to dispose the connection we no longer need it. But again if you don’t really need the related data in real time you can use this easy way to join two references.
For a complete reference of Firebase use this link
For a complete list of querying functions you ca use this link.
If you found this post useful please don’t forget to press the like button and share it. If you are in doubt don’t hesitate to ask a question and as always thank you for reading.