neumino / thinky

JavaScript ORM for RethinkDB
http://justonepixel.com/thinky/
Other
1.12k stars 128 forks source link

Optimize orderBy when ordering is desc #634

Open hgrubst opened 7 years ago

hgrubst commented 7 years ago

Currently orderBy in thinky optimizes the query if an index is found on the Model. As described in the documenation :

The command orderBy is optimized only when a string is passed as the first argument.

Unfortunately if you need to orderBy desc, this does not work as you need to pass your query in the form : User.orderBy(r.desc('lastName')) which is then not passing a string anymore.

Is there a workaround for this ? Or would it be possible to have thinky overload the orderBy method say by adding a 2nd parameter (boolean) as the order of the sort ?

jojo-tutor commented 6 years ago

Same issue here