Created
February 1, 2013 04:42
-
-
Save scien/4689274 to your computer and use it in GitHub Desktop.
.mongorc.js example
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
prompt = function() { | |
var ndocs, obj, p, sec; | |
ndocs = function(n) { | |
return "" + n + " document" + (n > 1 ? 's' : ''); | |
}; | |
db.setProfilingLevel(2); | |
obj = db.getLastErrorObj(); | |
p = db.system.profile.find({ | |
$and: [ | |
{ns: {$not: /profile$/}}, | |
{ns: {$not: /\$cmd$/}}, | |
{ns: {$not: /indexes$/}} | |
] | |
}).sort({ts: -1}).limit(1)[0]; | |
sec = "" + (p.millis / 1000) + " sec"; | |
if (obj.err) { | |
return "Error: " + obj.err + "\n> "; | |
} | |
switch (p.op) { | |
case 'insert': | |
return "Query OK, 1 document inserted (" + sec + ")\n> "; | |
case 'query': | |
return ">= " + (ndocs(p.nreturned)) + " in set (" + sec + ")\n> "; | |
case 'remove': | |
return "Query OK, x documents removed (" + sec + ")\n> "; | |
case 'update': | |
return "Query OK, " + (ndocs(p.nupdated)) + " affected (" + sec + ")\n> "; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment