Skip to content

Instantly share code, notes, and snippets.

@methodin
methodin / Mongo
Created February 1, 2011 15:20
Useful commands/examples for Mongo
// Adding a user auth to a DB (read/write, add true as a third param for read-only)
use somedb
db.addUser("username","pasword")
// Update an entry (don't forget $set or it will be replace only with what is provided)
db.gadgets.update({key:"Some criteria"},{$set:{weight:17.6}})
// Dump a database/collection
mongodump -d databasename -c collection -o .