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

193
Views
Valid way to delete a doc from firebase

I want to delete a game from my firestore collection, but i get error:

TypeError: doc is not a function

I am using the latest version of Firebase. What is the proper way to delete the doc?

import {where,query,deleteDoc,collection, doc, getDocs, getFirestore } from "firebase/firestore";
    
deleteGame(game)  {            
  const db = getFirestore();
  const q = query(collection(db, "history"), where("date", "==", game.date));
  const doc = getDocs(q);
  const quer = await getDocs(q);

  quer.forEach((doc) => 
   {    
       deleteDoc(doc(db, "history", doc.id));
   });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to firebase documentation for delete data you should indeed use

deleteDoc(doc(db, "history", doc.id));  

But doc needs to be the function imported from firebase/firestore . You are rewriting the value of doc with the element from quer ( quer.forEach((doc) => ).

You also have const doc = getDocs(q); so you will need change the name of both doc variables in order to use the imported function inside the forEach callback.

Also keep in mind that this won't subcollections (if you have any - as specified in the docs).

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!