I have created the following structure in my firestore:
/Users/USERID/Chats/UNKNOWN_DOCUMENT_ID/isClicked/isClicked-> Field: isClicked = 0/1
Which is:
/collection/document/collection/document/colection/document/Field
Now, I want to add an option for users to delete their account which also means to delete the path above. However, I cant figure out how to delete it.
I tried to do the following:
db.collection( "Users" ).document(auth.getUid()).collection("Chats").get()
.addOnCompleteListener( task -> {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
if (document != null) {
db.collection( "Users" ).document(auth.getUid()).collection("Chats").document(document.getId()).collection("isClicked").document("isClicked").delete();
}
}
}
} );
But I keep getting that task.getResult
size is 0 and there is no document even though that there is a document for sure but I don't know its ID.
Any solution to how to delete it?
I read that it is not recommended to delete the collection from within the code but still.
Thank you