Last active
December 14, 2017 01:27
-
-
Save travist/08d3a5684d98a3c14d144fd130c60c96 to your computer and use it in GitHub Desktop.
Clean up MongoDB for Form.io project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.projects.find({_id: ObjectId('<PROJECT_ID>')}).forEach(function(project) { | |
| print('Deleting roles for project ' + project._id); | |
| db.roles.deleteMany({project: project._id}); | |
| print('Deleting form revisions for project ' + project._id); | |
| db.formrevisions.deleteMany({project: project._id}); | |
| db.forms.find({project: project._id}).forEach(function(form) { | |
| print('Deleting actions for form ' + form._id); | |
| db.actions.deleteMany({form: form._id}); | |
| print('Deleting submissions for form ' + form._id); | |
| db.submissions.deleteMany({form: form._id}); | |
| print('Deleting form ' + form._id); | |
| db.forms.deleteOne({_id: form._id}); | |
| }); | |
| print('Deleting project ' + project._id); | |
| db.projects.deleteOne({_id: project._id}); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment