Small information nuggets and recipies about MongoDB
✂️ MongoDB
(most recent on top)
Cleanup a single collection
mongo 'dbname' --eval 'db.collectionName.remove({})'
… example
mongo 'agent-paye' --eval 'db.optedInUsers.remove({}); db.termsAndConditions.remove({})'
Drop all databases / collections
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(
function(i) { db.getSiblingDB(i).dropDatabase() }
)'
Launch MongoDB on demand
mongod --config /usr/local/etc/mongod.conf &