Skip to content

Instantly share code, notes, and snippets.

@mfo
Created June 24, 2011 15:28
Show Gist options
  • Save mfo/1045022 to your computer and use it in GitHub Desktop.
Save mfo/1045022 to your computer and use it in GitHub Desktop.
from mongo console :
# a few usefull command on mongo cli
show dbs
use sharypic_development
# adding sparse index
db.users.dropIndex("invite_code_1")
db.users.ensureIndex({invide_code: 1}, {sparse: true, unique: true})
# rename a datbase
use 'sharypic-staging'
db.copyDatabase("sharypic-staging", "sharypic_development", this)
db.getCollecitonNames()
# querying object id
{_id: ObjectId('blah')}
# removing stuffs
db.pictures.remove({ $and: [ {"event_id": ObjectId('4e11adb84fcd230001000044')}, {"_type": {$ne: "TwitterSource"}}] })
# restore a db
mongorestore -vvv sharypic_development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment