Title: React Native Firebase delete user data
Tags: firebase;react-native
Question: How can I make a function that deletes all todos that the user has?
This is a function that I am calling
https://i.stack.imgur.com/evR3D.png
this is on a button press function call
https://i.stack.imgur.com/BsbY2.png
And this is end result error
https://i.stack.imgur.com/n6RnE.png
Comment: It's helpful if you paste code rather than screenshots.


Here is another answer: delete is not an available function on a collection. Deleting an entire collection is not recommended, and thus you have to iterate through the documents and delete them individually. From the official Firebase documentation:
To delete an entire collection or subcollection in Cloud Firestore, retrieve all the documents within the collection or subcollection and delete them. If you have larger collections, you may want to delete the documents in smaller batches to avoid out-of-memory errors. Repeat the process until you've deleted the entire collection or subcollection.
Source: https://firebase.google.com/docs/firestore/manage-data/delete-data#web_2
To get all of the documents in the collection, you can do this:
const snapshot = await firebase.firestore().collection(COLLECTION_NAME).get()
And then you can iterate through snapshot.docs and delete each one. Keep in mind that each delete call will be async, so unless you don't care about when everything finishes, you may want to use Promise.all or something to keep track of when all of the async actions finish.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:02/20/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<firebase><react-native>', 'Title': 'React Native Firebase delete user data', 'ViewCount': 254, 'id': 66292933, 'user_AboutMe': None, 'user_AccountId': 19894342.0, 'user_DisplayName': 'Filip', 'user_Reputation': 1.0, 'user_Views': 2.0, 'user_id': 14575710.0}}