Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda