Tsallaka zuwa abun ciki
Justice Tech School

Sort, Limit and Skip

sort orders results, 1 ascending and -1 descending. limit caps the count and skip jumps over documents for pagination.

Example
db.students.find().sort({ age: -1 }).skip(10).limit(5)

Exercise

Newest first.

.sort({ age:  })

Quiz Test

What does -1 mean in sort?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.