Skip to content

Instantly share code, notes, and snippets.

@travist
Last active July 31, 2023 14:49
Show Gist options
  • Save travist/5133ade419362685bb81d29034be4c2d to your computer and use it in GitHub Desktop.
Save travist/5133ade419362685bb81d29034be4c2d to your computer and use it in GitHub Desktop.
Mongo Delete multiple projects and resources within it.
db.projects.find({_id: {$in: [
ObjectId('63ebe4e2902342342db152a8'),
ObjectId('642324234234a13675034017'),
ObjectId('642c68506234234234241869'),
]}}).forEach(function(project) {
print('Deleting project ' + project.name);
db.submissions.deleteMany({project: project._id});
db.actions.deleteMany({project: project._id});
db.formrevisions.deleteMany({project: project._id});
db.forms.deleteMany({project: project._id});
db.roles.deleteMany({project: project._id});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment