How can I check if a collection exists or not in firestore?
There is a method to check document exist. Such as:
this.afs.doc('users/' + userId).ref.get().then((doc) => {
if (doc.exists) {
console.log("User alread exists")
} else {
console.log("User first login")
}
}).catch(function (error) {
console.log("Error getting document:", error);
});
But I could not find a method to check the collection. In my case, I don't know if any document exists. So, I cannot use
this.afs.doc
to get the document. I want to check the root collection existence.