Firebase V9 Firestore DELETE Document Using deleteDoc()

Raja Tamil
2 min readSep 5, 2022

Learn how to delete a document from a collection in Firebase version 9 Cloud Firestore using the deleteDoc() method.

Here is the sample document from the cities collection in Cloud Firestore Database that I want to delete.

First, import Firestore Database and de-structure the three methods we need:

  • getFirestore()
  • doc()
  • deleteDoc()

import { getFirestore, doc, deleteDoc } from "firebase/firestore";

Initialize Firestore Database and assign it to the constant db.

const db = getFirestore();

The deleteDoc() method takes one method as an argument to perform the delete operation which is

  • doc()

The doc() method takes three arguments which are:

  • database → db
  • collection name → cities
  • document ID → yftq9RGp4jWNSyBZ1D6L (ID of a document…

--

--

Raja Tamil
Raja Tamil

Written by Raja Tamil

👇click the link and get 80% OFF on the premium web development courses (HTML5, CSS3, JavaScript ES6, Vue JS 3 & Firebase 10 https://softauthor.com