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

Conditional order? #651

Closed
fivethousand opened this Issue Feb 9, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@fivethousand

fivethousand commented Feb 9, 2017

Is there a way to allow for queries with a conditional order?

Example (does not compile):

let order = match order_string {
  "id" => id,
  "name" => name,
  "age" => age,
  _ => id
};
let results = users.order(order).load::<User>(&connection);

Do we really have to duplicate like this?

let results = match order_string {
  "id" => users.order(id).load::<User>(&connection),
  "name" => users.order(name).load::<User>(&connection),
  "age" => users.order(age).load::<User>(&connection)
  _ => users.order(id).load::<User>(&connection)
};
@sgrif

This comment has been minimized.

Member

sgrif commented Feb 9, 2017

You'll need to box either the order or the whole query. See the examples in the docs here and here

@sgrif sgrif closed this Feb 9, 2017

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