0

hi so i have a collection called users, in users theres a doc with users id. then in the users id there is a collection called lists and in that collection theres a document.

I basically want to delete everything based on the current users id in firebase.

firebase.firestore().collection('users').doc(user.uid).collection('lists').doc('lists').delete();

i thought the above would work but its not, as im not sure how to rever to the doc inside of the collection lists, as each list inside the last document has different ids how do i delete them all? as i want to delete the whole collection based on user id

danartillaga
  • 1,349
  • 1
  • 8
  • 19
codergirl
  • 25
  • 1
  • 7

1 Answers1

1

According to the firebase documentation,

To delete an entire collection or subcollection in Firestore, retrieve all the documents within the collection or subcollection and delete them.

So you'll want to retrieve all documents on the list collection of a user then delete them.

danartillaga
  • 1,349
  • 1
  • 8
  • 19