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

223
Vistas
How to delete a field in a collection with firebase-admin?

I have a collection like this into firebase realtime database:

enter image description here

I need to delete the first element (the one that finishes with Wt6J) from server side using firebase-admin.

I have this simple code:

const deleteNotification = () => {
  const key1 = 'FhN6Ntw8gyPLwJYVzcHy0E8Wq5z2';
  const key2 = '-MzGhZ2psGLivIfTWt6J';
  const notsRef = db.ref(`notifications/${key1}/${key2}`);
  notsRef.remove();
};

This doesn't work. What method should I use to delete a specific field? How do you think I can do it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would think to use await in a try catch block. Await starts another thread which returns once it has completed. As people said above - your cloud function is likely being killed before the remove actually happens.

const deleteNotification = async () => {
  try{
    const key1 = 'FhN6Ntw8gyPLwJYVzcHy0E8Wq5z2';
    const key2 = '-MzGhZ2psGLivIfTWt6J';
    const notsRef = db.ref(`notifications/${key1}/${key2}`);
    await notsRef.remove();
  } catch( err ) {
    console.log( 'failed to remove record.' );
    console.log( err );
  }
  console.log( 'removed record successfully.' );
};
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