Over a million developers have joined DZone.

Firebase Advance Querying Join Reference

DZone's Guide to

Firebase Advance Querying Join Reference

In this post, we go over how to use the Firebase querying system to create a query that will join two different references.

· Mobile Zone ·
Free Resource

What’s up guys, Eze is here. I already did a 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 advanced 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 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 just once. Also important to note is that this data is not going to be live data, so 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 get rid of the connection when 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 can 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.

firebase ,query ,javascript

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}