3👍
✅
Update following your comment below (explaining that actually this.user.uid
is not the id of the Firestore document)
So you should indeed execute a query and when you get the result of this query (in the then()
method), delete the (unique) document returned by the query, as follows:
var query = db.collection('Users').where('user_id', '==', this.user.uid);
query.get()
.then(function(querySnapshot) {
var docSnapshot = querySnapshot.docs[0]; // We get the first (and unique) document of the querySnapshot
docSnapshot.ref.delete();
});
You don’t need to use a Query for that (using where()
defines a Query).
You can just point to the document (i.e. define a DocumentReference
) and call the delete()
method, as follows.
db.collection('Users').doc(this.user.uid).delete();
Source:stackexchange.com