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

317
Views
How can I delete a doc with a where query in Firebase v9?

I have a collection where it contains a couple of docs which all contains a id-field individual. But i can't figuere out how I can delete a specific document based on my query. I have tried with this:

 const deleteItem = async(item) => {
    const d = query(collection(db, 'allTasks'), where('id', '==', item.id));
    const docSnap = await getDocs(d);
    docSnap.forEach((doc) => {
      console.log(doc.data())
      deleteDoc(doc.data());
    });
  }

But i get the error: [Unhandled promise rejection: TypeError: t is not an Object. (evaluating '"_delegate" in t')]

Is this the wrong way or should i use batch? The console.log shows the right item that i have clicked delete on

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The deleteDoc() function take DocumentReference as parameter and not the document data.

docSnap.forEach((doc) => {
  deleteDoc(doc.ref); // and not doc.data()
});

Additionally, it might be a good idea to use a batch to delete documents to ensure they are all delete or none.

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!