KEMBAR78
Mongodb | PDF | Databases | Computer Programming
0% found this document useful (0 votes)
17 views1 page

Mongodb

This document is a MongoDB cheat sheet that provides basic commands for interacting with MongoDB like starting MongoDB, selecting databases, finding documents, and querying documents. It also includes options for sorting, skipping, and limiting results from find queries.

Uploaded by

Google User
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Mongodb

This document is a MongoDB cheat sheet that provides basic commands for interacting with MongoDB like starting MongoDB, selecting databases, finding documents, and querying documents. It also includes options for sorting, skipping, and limiting results from find queries.

Uploaded by

Google User
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MongoDB Cheat Sheet

by Ovidiu Anicai (ovi_mihai) via cheatography.com/4776/cs/916/

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!
cheatography.com/ovi-mihai/ and was last updated on 27th March, 2013. Try it free!
0v1.ro http://www.FeedbackFair.com

You might also like