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

333
Views
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 answers
Answer question

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 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!