Skip to content

Instantly share code, notes, and snippets.

@victorcampos
Created July 1, 2011 15:23
Show Gist options
  • Save victorcampos/1058767 to your computer and use it in GitHub Desktop.
Save victorcampos/1058767 to your computer and use it in GitHub Desktop.
MongoDB - Drop tmp.mr for temporary mapReduce collections
db.system.namespaces.find({ name : /tmp.mr/ }).forEach(function(z) {
try {
db.getMongo().getCollection( z.name ).drop();
} catch (exception) {
try {
db.getMongo().getCollection( z.name.replace("$", "\\$") ).drop();
} catch(exception2) {
printjson({ error : 'error dropping collection', e : exception });
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment