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.
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 ofmy_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!