-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Labels
🔧 fixBug fixes and code patchesBug fixes and code patches
Description
Originally posted by tkelley-eg June 2, 2025
What features would you like to see added?
The current delete-user script only deletes the document from the user
collection.
It would be nice if the script support an optional arg that would delete records related to the user from other collections.
I think with mongoose that dependent documents can be sought out to avoid hard-coding of these dependencies.
More details
In addition to some poking around, I ran an AI analysis to see if there was some background job doing cleanup.
- delete-user Script
The config/delete-user.js script only deletes the user document from the User collection in MongoDB.
There is no evidence in this script of additional cleanup for other collections referencing this user.
View source - Evidence of Cleanup Scripts
No scheduled job or cron script was found in the repository for orphan cleanup. There’s no mention of a recurring cleanup process in the package scripts or config files.
However, there is a script at e2e/setup/cleanupUser.ts that, given a user, explicitly deletes related data from multiple collections:
Deletes all user messages (deleteMessages).
Deletes all user sessions.
Deletes from User, Balance, and Transaction collections.
Deletes conversations and associated messages (deleteConvos).
This cleanup script appears to be used for test teardown, not as an automated or scheduled production cleanup:
View source - Other Collections That Reference Users
There are functions for deleting user-specific data in other models (e.g., deleteMessages, deleteConvos, deleteActions, deleteAllSharedLinks), but these are not invoked by the main delete-user script.
No evidence was found that these are run automatically after user deletion unless triggered manually or via test teardown. - No Scheduled/Automated Cleanup
No scheduled job (cron, interval, or workflow) was found that periodically cleans up orphaned documents.
No documentation or comments describe such a scheduled system.
Summary:
The standard delete-user script only removes the user record itself. There is no evidence of an automated or scheduled script that later cleans up orphaned documents in other collections. The only comprehensive cleanup found is in a manual/test teardown script, not used in normal operations.
If you need orphaned data removed in production, you will likely have to extend the delete-user script to invoke the relevant cleanup routines for other collections.
Which components are impacted by your request?
Other
Pictures
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
🔧 fixBug fixes and code patchesBug fixes and code patches