Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$sort operator #9

Closed
robitex opened this issue Aug 21, 2018 · 1 comment
Closed

$sort operator #9

robitex opened this issue Aug 21, 2018 · 1 comment

Comments

@robitex
Copy link

robitex commented Aug 21, 2018

Hi all,
Is there a chance to have got the $sort operator for query option or as a cursor method?
For my understanding, your project doesn't support server side sorting. Does it?
Thank you.
R.

@neoxic
Copy link
Owner

neoxic commented Aug 23, 2018

Sorting is done via query options as per MongoDB's command syntax. Options are passed to mongo-c-driver as-is, so your best bet is to always refer to MongoDB's documentation first. See this for example:

-- Iterate documents in a for-loop
local age_desc = mongo.BSON{sort = {age = -1}}
for person in collection:find({}, age_desc):iterator() do
    print(person.name, person.age)
end

@neoxic neoxic closed this as completed Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants