0

The Document I am trying to Delete

I want to delete a document which is further having collections inside it. I am running this code

db.collection("users").document(uid)
        .delete()
        .addOnCompleteListener {
            if (it.isSuccessful) {
                Log.i("logcat", "Success")

            } else {
                Log.i("logcat", "Fail")
            }
        }

The output in Logcat is Success still I see the document present on the console. However when i mention the complete reference(db.collection("users").document("uid).collection("amount")........), individual documents inside it gets deleted but I need to delete the document with all its collections inside. Am I trying it the wrong way or some limitation of Firebase?

1 Answers1

0

Welcome to Stackoverflow!

In this case to delete subcollections you need to read this: https://firebase.google.com/docs/firestore/solutions/delete-collections

Basically you will need to use a recursive delete like this:

await firebase_tools.firestore
  .delete(path, {
    project: process.env.GCLOUD_PROJECT,
    recursive: true,
    yes: true,
    token: functions.config().fb.token
  });
Welyngton Dal Prá
  • 758
  • 1
  • 10
  • 19