module Jennifer::QueryBuilder::Ordering
Direct including types
Defined in:
jennifer/query_builder/ordering.crInstance Method Summary
-
#order(opts : Hash(String, String | Symbol))
Allow to specify an order by hash with string keys.
-
#order(opts : Hash(Symbol, String | Symbol))
Allow to specify an order by hash with symbol keys.
-
#order(opt : OrderExpression)
Allow to specify an order by OrderExpression.
-
#order(opts : Array(OrderExpression))
Allow to specify an order by OrderExpression array.
- #order(opts : Hash(String | Symbol, String | Symbol))
-
#order(**opts)
Allow to specify an order by splatted named tuple.
-
#order(&)
Allow to specify an order passing a block.
-
#ordered?
Show whether order is specified.
- #reorder(opts : Hash(String, String | Symbol))
- #reorder(opts : Hash(Symbol, String | Symbol))
- #reorder(opt : OrderExpression)
- #reorder(opts : Array(OrderExpression))
- #reorder(opts : Hash(String | Symbol, String | Symbol))
-
#reorder(**opts)
Replace an existing order with the newly specified.
- #reorder(&)
Instance Method Detail
Allow to specify an order by hash with string keys.
Contact.all.order({"name" => :asc})
Allow to specify an order by hash with symbol keys.
Contact.all.order({:name => :asc})
Allow to specify an order by OrderExpression.
Contact.all.order(Contact._name.asc)
Allow to specify an order by OrderExpression array.
Contact.all.order([Contact._name.asc])
Allow to specify an order by splatted named tuple.
Contact.all.order(name: :asc)
Allow to specify an order passing a block.
Contact.all.order { _name.asc }
Contact.all.order { [_name.asc, _age.desc] }
Specified block should return OrderExpression | Array(OrderExpression)
.
To convert Criteria
or RawSql
to order item call #asc
or #desc
.
Replace an existing order with the newly specified.
Contact.all.order(name: :asc).reorder(age: :desc) # ORDER BY contacts.age DESC