DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Firebase Advance Querying Join Reference

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.

Ezequiel Reyno user avatar by
Ezequiel Reyno
·
Mar. 17, 17 · Mobile Zone · Tutorial
Like (4)
Save
Tweet
33.02K Views

Join the DZone community and get the full member experience.

Join For Free

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.

database_schema.png

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.

query_first

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.

query_second.PNG

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.

Joins (concurrency library) Firebase Data (computing)

Published at DZone with permission of Ezequiel Reyno. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Is NoOps the End of DevOps?
  • SQL vs. NoSQL: Pros and Cons
  • What Are Microservices?
  • How to Submit a Post to DZone

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo