-
Notifications
You must be signed in to change notification settings - Fork 3
Minimongo: make hint: $natural available on client, too #413
Comments
@jankapunkt I believe it was not included because nobody asked. |
I believe I have some experience with
And the natural order definition:
Now, this is quite unspecified for if (this.sorter) {
results.sort(this.sorter.getComparator({distances}));
- }
+ // Unspecified `$natural` and `$natural: -1` are equivalent to no reordering.
+ } else if (this.naturalHint === 1) {
+ results.reverse();
+ } Other things to do: correct this test, this piece of documentation, and this note. What is your use case, @jankapunkt? I've never actually used |
I am using to retrieve documents from the newest without having to use sort. So basically I get the latest n Docs via $natural set to -1 and limit to n. In my naive thinking I thought that this is way performant than sorting the whole collection. Edit: this mostly happens on the server but I wrote some isomorphic Code where splitting Server/Client because of one line seems to me very inefficient. |
@jankapunkt I'd still suggest an index then. Also, keep in mind that |
As far as I can see from the docs, there is no
hint: $natural
option available on the client.Is there a reason why? From my understanding it simply reverses the search order from latest to oldest. If I get this right we simply would have to support a optional backwards count in this line in
minimongo/cursor.js
:However, I am not deep enough into this file yet to see potential sideeffects. Anyone with experience on
minimongo
internals here?The text was updated successfully, but these errors were encountered: