Scille / umongo

sync/async MongoDB ODM, yes.
MIT License
448 stars 63 forks source link

sort direction does not work #344

Closed jbkoh closed 3 years ago

jbkoh commented 3 years ago

Hi,

I realized that the direction in sort function does not work with - sign. I'm also not sure if it's actually supported, because it's not documented. Let me know if I missed it.

I want MyDocument.find({}).sort("-my_version").limit(1) to indicate that I want to sort the results by descending order of my_version field like this. The query returns results without an error but they are still in the ascending order.

I'm also curious if it's just sorting the results set after pulling all the data from the db, or actually receiving sorted and limited results (in this case only one document) from the database.

Thanks!

jbkoh commented 3 years ago

And, does umongo have an API to send a raw query to the database?

jbkoh commented 3 years ago

Found that the sort is an alias to Motor APIs. I'm using -1 explicitly, and it's working. thanks