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

Support MongoDB sort by multiple fields #41

Closed
pfurio opened this issue Nov 4, 2019 · 0 comments
Closed

Support MongoDB sort by multiple fields #41

pfurio opened this issue Nov 4, 2019 · 0 comments
Assignees

Comments

@pfurio
Copy link
Member

pfurio commented Nov 4, 2019

At the moment, the datastore module of mongoDB only supports sorting documents by one field. Sorting can be done using the following keys "ASC", "ASCENDING" or "1" for ascending order; "DESC", "DESCENDING" or "-1" for descending order. We should support sorting by multiple fields allowing to pass a list of strings following this nomenclature:

field:order

Example: We want to retrieve all the documents sorted first by a priority value (1-5) in descending order and creation date in ascending order.

QueryOptions options = new QueryOptions(QueryOptions.SORT, Arrays.asList("priority:DESC", "creationDate:ASC"));

@pfurio pfurio self-assigned this Nov 4, 2019
@pfurio pfurio closed this as completed in b655b8f Nov 4, 2019
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

1 participant