Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
Cloud Functions for Firebase: admin vs root lookups

Getting the hang of Firebase and JavaScript for coding cloud functions; but I guess I'm looking if anyone can explain the pros and cons of using the following for look-ups and/or writes in cloud functions?!

  1. the use of admin.database().ref()
    vs
  2. root.child()

I myself have been using admin.database.ref(), but do I need to? Is it just as good to use the root.child() instead?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I see that you've also asked this question in the comments for my Firecast on YouTube. That's a good question. If you've been following along with the Cloud Functions for Firebase samples, you might have seen admin.database().ref().

admin.database().ref() uses the Firebase admin SDK to access data in the Database. As an admin reference, it has unrestricted access to any part of the Database.

In the video, root = event.data.ref.root, a reference to the root of the database where the .onWrite event occurred. ref has the same read and write access as the user who triggered the event. Unlike admin.database().ref(), it does not grant unrestricted access. root.child therefore access that specific path in the database, as long as the user has permission to access it.

Now event.data.adminRef.root is a Database reference with unrestricted access to any part of the Database. If this sounds like admin.database.ref(), it's because they're exactly alike. In my case, I chose event.data.ref.root to limit the amount of new topics introduced in one video. If you're more comfortable using the admin SDK, that is totally fine.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!