Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Mongo Basics Go Further With Mongo Doing More With Queries in Mongo

so when you use sort and then replace with limit is list still sorted?

for instance:

db.posts.find({}{title: true}).sort({title: 1})

db.posts.find({}{title: true}).limit(2).skip(2)

basically since we used sort method the list is now sorted, and then we can step through it with limit and skip am I right? or do you have to keep sort in there

db.posts.find({}title: true}).sort({title:1}).limit(2).skip(2)

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Thomas;

Each separate request will be an atomic request to the database, so if you want it to sort and limit and skip, you would have to do that as one request.

Happy coding,
Ken