2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
cheat.sheets/sheets/_mongo/cursor

17 lines
479 B
Plaintext
Raw Normal View History

2018-01-06 17:19:18 +00:00
// Show number of documents in the collection
db.books.find().count()
// Limit the number of documents to return
db.books.find().limit(2)
// Return the result set after skipping the first n number of documents
db.books.find().skip(2)
// Sort the documents in a result set in ascending or descending order of field values
db.books.find().sort( {title : 1} )
// value = 1 for ascending, -1 for descending
// Display formatted (more readable) result
db.books.find({}).pretty()