Mongodb Cheat Sheet

ADVERTISEMENT

MongoDB Cheat Sheet
by
Ovidiu Anicai (ovi_mihai)
via
Basic commands
Finds - db.collection
Mongo Queries
mongo
Start Mongo
.find()
Displays documents from "collectio
_id
Search by ID
n" (first 10)
show dbs
Show databases
key: value
Search through key-value combin
it
Type "it" to see more documents
ation
use mydb
User database named "mydb"
after the prev command
{ subkey: value
Search with subdocument
db
Show selected database
.find( query [,
Find all documents by conditions,
}
help
Get help
fields] )
with optional fields selection
$in : [ e1, e2, ..
Search IN Array
show collections
Show collections from a database
.findOne( query
Find one document by conditions
]
)
queries are represented through JSON objects
.find( query )
Find n document by conditions
.limit( n:number
)
.find() .pretty()
Format results in Mongo Shell
.find() .sort( key :
Sort by key in ascending (1) or
1|-1 )
descending (-1) order
.find() .skip( 5 )
Skip 5 documents (similar to offset)
Cheatographer
Cheat Sheet
Sponsor
Ovidiu Anicai (ovi_mihai)
This cheat sheet was published on 27th March, 2013
FeedbackFair, increase your conversion rate today!
and was last updated on 27th March, 2013.
Try it free!
0v1.ro

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go