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

use Sort vararg for ordering of query results #1043

Closed
wants to merge 7 commits into from

Conversation

cstrempfer
Copy link
Contributor

Instead of
datastore.find(Rectangle.class).order("width,-height").get();
you can now write
datastore.find(Rectangle.class).order(ascending("width"), descending("height")).get();

This partially solves #735. I didn't implement methods to chain sort parameters.

The Sort class is in org.mongodb.morphia.aggregation right now. It could be moved to org.mongodb.morphia.utils as it's used for queries and aggregation now, but that will break existing code.

@cstrempfer cstrempfer changed the title Issue735 use Sort vararg for ordering of query results Oct 14, 2016
@evanchooly evanchooly added this to the 1.3.0 milestone Oct 14, 2016
@evanchooly
Copy link
Member

Thanks! This looks great. I have a few tweaks I want to make to address the package issue you mentioned but I think we can get this merged next week.

@cstrempfer
Copy link
Contributor Author

@evanchooly I've made the changes you suggested in #499. It wasn't necessary to change the type of Sort#order (aka. Sort#direction).

I didn't change the unit tests of sorting in an aggregation pipeline to make sure the old API still works.

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

Successfully merging this pull request may close these issues.

2 participants