1

My problem is that I want to return the docs of the last five created entries in the database. I know that something like:

return Events.find({}, {sort: {createdOn: -1, limit: 5}});

should work but it does not.

1 Answer 1

3

The sort specifier should be a separate property to the limit option:

return Events.find({}, {sort: {createdOn: -1}, limit: 5});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.