Skip to content

Commit

Permalink
Document using a fragment with order_by/3 (#2271)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanl authored and josevalim committed Oct 12, 2017
1 parent 657e1a2 commit dac4fbd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ecto/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 966,14 @@ defmodule Ecto.Query do
values = [asc: :name, desc: :population]
from(c in City, order_by: ^values)
A fragment can also be used:
from c in City, order_by: [
# a deterministic shuffled order
fragment("? % ? DESC", c.id, ^modulus),
desc: c.id,
]
## Expressions example
City |> order_by([c], asc: c.name, desc: c.population)
Expand Down

0 comments on commit dac4fbd

Please sign in to comment.