Pagination & Ordering

Pagination

For now you can only specify limit and offset:

Contact.all.limit(10).offset(10)

Order

You can specifies orders to sort by:

# named tuple
Contact.all.order(name: :asc, id: "desc")
# symbol key hash
Contact.all.order({:name => :asc})
# string key hash
Contact.all.order({"name" => :asc})
# with block returning array of Jennifer::QueryBuilder::OrderExpression
Contact.all.order { [_name.asc] }
# or pass it as an argument
Contact.all.order(Contact._name.asc)

Any symbol-based names are considered as a column names. Any string-based - as raw SQL.

Reorder

To avoid all existing ordering and assign new one:

c = Contact.all.order(name: :desc)
c.reoder(id: :asc).to_a