Skip to content

Instantly share code, notes, and snippets.

@domharrington
Created December 5, 2014 11:38
Show Gist options
  • Save domharrington/a4d10437d92b4df047bc to your computer and use it in GitHub Desktop.
Save domharrington/a4d10437d92b4df047bc to your computer and use it in GitHub Desktop.
.mongorc.js file
DBCollection.prototype.read = function (id) {
return this.findOne({ _id: ObjectId(id) })
}
DBCollection.prototype.delete = function (id) {
return this.remove({ _id: ObjectId(id) })
}
function notablescan() {
var currentValue = db.getSiblingDB('admin').runCommand({ getParameter: 1, notablescan: 1 }).notablescan
printjson(db.getSiblingDB('admin').runCommand({ setParameter: 1, notablescan: !currentValue }))
}
function clearUpTestDbs() {
var dbs = db.adminCommand('listDatabases').databases
dbs.forEach(function (database) {
if (database.name.match(/^test.+/)) {
print('Dropping DB: ' + database.name)
db.getSiblingDB(database.name).dropDatabase()
}
})
}
clearUpTestDbs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment