To do house keeping job on Mongo DB we can use scripting for it
Steps involved will be
1) Write a java script file using the details given in http://docs.mongodb.org/manual/tutorial/write-scripts-for-the-mongo-shell/2) To run a script use comand : mongo.js 3) If you want to get the shell also when executing like this : mongo testConnction.js --shell
testJsScript.js
` db = connect("localhost:27017/myDatabase"); // db contain the reference of the database printjson(db.getCollectionNames()); // mongodb provided print command print(db.getCollectionNames()); //js print command cursor = db.collection.find(); // this will return a cursor, this cursor can be used to iterate over all the collection object.
you can even use this cursor for updating items, but the catch is you have to fire a query which actually return only the json object which can be directly used in the query.