Home > Software design >  How can I get the id of a inserted document firebase-admin
How can I get the id of a inserted document firebase-admin

Time:04-22

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 enter image description here

CodePudding user response:

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)
  • Related