Skip to content

Instantly share code, notes, and snippets.

@byplayer
Last active August 29, 2015 14:08
Show Gist options
  • Save byplayer/b190ff1ab94a6f7a0abc to your computer and use it in GitHub Desktop.
Save byplayer/b190ff1ab94a6f7a0abc to your computer and use it in GitHub Desktop.
mongo
//
// concept
database
- collection(table)
- document(row)
- field(column)
//
// definition
// use [database name]
use [database name]
// show databases
show dbs
// show tables
show collections
// drop database
use [target database name]
db.dropDatabase()
// index
// create index
db.unicorns.ensureIndex({name: 1});
// drop index
db.unicorns.dropIndex({name: 1});
// unique index
db.unicorns.ensureIndex({name: 1}, {unique: true});
// comprex index
db.unicorns.ensureIndex({name: 1, vampires: -1});
// explain
db.unicorns.find().explain()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment