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

add natural order support #499

Closed
evanchooly opened this issue Jul 30, 2013 · 5 comments
Closed

add natural order support #499

evanchooly opened this issue Jul 30, 2013 · 5 comments
Milestone

Comments

@evanchooly
Copy link
Member

http://docs.mongodb.org/manual/reference/operator/natural/#op._S_natural

@evanchooly evanchooly added this to the 0.108 milestone Feb 28, 2014
@trishagee
Copy link
Contributor

This can be achieved at the moment using

Query.order("$natural")

and

Query.order("-$natural")

So I'm de-scoping it from the 0.108 milestone

@trishagee trishagee removed this from the 0.108 milestone Apr 22, 2014
@evanchooly evanchooly added this to the post-1.0 milestone Jun 5, 2014
@evanchooly evanchooly removed this from the post-1.0 milestone Jan 14, 2016
@evanchooly evanchooly added this to the 1.3.0 milestone Jun 13, 2016
@cstrempfer
Copy link
Contributor

I could add an solution for that to pull request #1043. Should there be explicit methods for that, e.g. Sort#ascendingNatural(), or is adding a constant NATURAL to the Sort class enough? I prefer the first option, because the constant could easily be missed by developers.

@evanchooly
Copy link
Member Author

I favor the explicit methods, too, though I wonder if naturalAscending() and naturalDescending() might be better. Either way is probably, fine, though. As for the package issue, I think a new Sort should be added outside the aggregation package. I'd use order rather than direction. The aggregation package's Sort would subclass the new one and cast order to int to preserve the existing API. Does that make sense?

@cstrempfer
Copy link
Contributor

I'd use order rather than direction.

Do you talk about the package name? If yes, I move it to order. If not, is the utils package, ok?

The aggregation package's Sort would subclass the new one and cast order to int to preserve the existing API.

What's the order part? I cannot find an order class in the master branch. Do you mean creating a new enum for the direction?

@evanchooly
Copy link
Member Author

evanchooly commented Oct 17, 2016

Instead of Sort#direction, I'd name it Sort#order and the order field would need to be Object to accomodate -1, 1, and the natural ordering values. As for the package, I think it should be alongside Query itself probably or the package above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants