MongoDB sorting and limiting explained

66 Views
Published
#MongoDB #course #tutorial

db.students.find()
db.students.find().sort({name: 1})
db.students.find().sort({name: -1})
db.students.find().sort({gpa: 1})
db.students.find().sort({gpa: -1})
db.students.find().limit(1)
db.students.find().limit(3)
db.students.find().sort({gpa: -1}).limit(1)
db.students.find().sort({gpa: -1}).limit(3)
Category
Bro Code
Tags
MongoDB course, MongoDB tutorial, MongoDB coding
Be the first to comment