To delete an existing document in Firestore, first you must add the FirebaseTS library to your project. Follow this tutorial to learn how to add FirebaseTS.
To delete an existing document in Firestore, first you must add the FirebaseTS library to your project. Follow this tutorial to learn how to add FirebaseTS.
Once you have added FirebaseTS, you are set to go!
Deleting Data
In this section, we will be deleting an document in Firestore using the delete() method from the FirebaseTSFirestore Class.
from - is an string array that points to the location of where to add the data to.
[
The first element of the array points to a collection and the second points to a document and the pattern repeats itself if more elements are added.
How to use
1. Import the FirebaseTSFirestore class.
import { FirebaseTSFirestore } from 'firebasets/firebasetsFirestore/firebaseTSFirestore';
2. Declare and initialize a FirebaseTSFirestore object.
3. Call the delete() method.
Handling code on complete or fail
Sometimes you may want to do something when you have successfully or unsuccessfully deleted a document in Firestore, like a notification message. You can add the optional parameters onComplete and onFail.