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

334
Vistas
Angular & Firebase Realtime-Database. How to get child knowing its id property but without knowing its parent node

My Database is like this

I can get to cart part on my own and I can even delete the product from cart.. if I type in the auto generated id manually.. Honestly, I have been trying to do this for 2 days now. I researched every stackoverflow question related to firebase database but I still couldn't figure it out.

I get to cart like this: firebase.database().ref('/' + account[0] + '_user' + '/cart')

But I can't go further.. assume that I am also providing product that needs to get deleted and you can access its id through item.id

Right now if you click on delete button the whole cart gets deleted.

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

0

If you know the product/id property of the node to delete, you can use a query to order/filter the nodes and find the key of the one(s) you want to delete:

const cartRef = firebase.database().ref('/' + account[0] + '_user' + '/cart');

const itemQuery = cartRef.orderByChild("product/id").equalTo(3);

itemQuery.get().then((snapshot) => {
  snapshot.forEach((productSnapshot) => {
    console.log(productSnapshot.key, productSnapshot.child("product/id").val());
  })
}).catch((error) => {
  console.error(error);
})
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