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

171
Views
How can I get the id of a inserted document firebase-admin

I am handling some documents with firebase realtime database. I need to delete a document that I don't have the access to read it client side via SDK. In order to do that I need to know what is the id, so I should store it in my db (mongo) and when I need to delete a document on firebase I just get it from my DB and the I delete it.

I took a look to this answer but it doesn't work for me.

I insert documents into my firebase DB with this method (server side using firebase-admin)

const writeNotification = (uid: string, notification: INotification) => {
  const db = admin.database();
  const notsRef = db.ref(`notifications/${uid}`);
  notsRef.push({
    ..._.omit(notification, 'to'),
  });
};

If I do notsRef.id I get undefined.

How can I get the ID of my document that I have just inserted?

p.s. my documents are organized like this:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The answer you are looking at is about Firestore and not Realtime Database that you are using. The Reference has a key property and not id:

console.log('New Key', notsRef.key) 

// to get child node's key
const childNotesRef = notsRef.push({
    ..._.omit(notification, 'to'),
  });

console.log(childNotesRef.key)
about 4 years ago · Juan Pablo Isaza 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!