I have a web application that stores in the firebase database companies, and inside those companies members. There is a scheduled task each night that goes through all companies and members and updates some information. I have deleted one company which had 12000 members, but the tasks for that company are still generated. The company and all members are deleted from the database, how are these tasks still appearing?
Can they somehow be stuck in the server tasks queue cache or something considering it was a really large company with lots of members? The company was deleted a couple of days ago and i am still confused and cant figure out why is this still happening.
Does anybody have any idea how is this possible?
Delete data from Cloud Firestore
Delete documents
To delete a document, use the following language-specific delete() methods:
Use the deleteDoc() method:
import { doc, deleteDoc } from "firebase/firestore";
await deleteDoc(doc(db, "cities", "DC"));
**Warning:** Deleting a document does not delete its subcollections!
When you delete a document, Cloud Firestore does not automatically delete the documents within its subcollections. You can still access the subcollection documents by reference. For example, you can access the document at path /mycoll/mydoc/mysubcoll/mysubdoc even if you delete the ancestor document at /mycoll/mydoc.
Non-existent ancestor documents appear in the console, but they do not appear in query results and snapshots.
If you want to delete a document and all the documents within its subcollections, you must do so manually. For more information, see Delete Collections.
**Delete fields**
To delete specific fields from a document, use the following language-specific FieldValue.delete() methods when you update a document:
Use the deleteField() method:
import { doc, updateDoc, deleteField } from "firebase/firestore";
const cityRef = doc(db, 'cities', 'BJ');
// Remove the 'capital' field from the document
await updateDoc(cityRef, {
capital: deleteField()
});
Delete collections 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.
Deleting a collection requires coordinating an unbounded number of individual delete requests. If you need to delete entire collections, do so only from a trusted server environment. While it is possible to delete a collection from a mobile/web client, doing so has negative security and performance implications.
The snippets below are somewhat simplified and do not deal with error handling, security, deleting subcollections, or maximizing performance. To learn more about one recommended approach to deleting collections in production, see Deleting Collections and Subcollections.
Delete data with the Firebase CLI You can also use the Firebase CLI to delete documents and collections. Use the following command to delete data:
firebase firestore:delete [options] <> Delete data with the console You can delete documents and collections from the Cloud Firestore page in the console. Deleting a document from the console deletes all of the nested data in that document, including any subcollections.
// Deleting collections from a Web client is not recommended.