module Jennifer::QueryBuilder::Ordering

Direct including types

Defined in:

jennifer/query_builder/ordering.cr

Instance Method Summary

Instance Method Detail

def order(opts : Hash(String, String | Symbol)) #

Allow to specify an order by hash with string keys.

Contact.all.order({"name" => :asc})

[View source]
def order(opts : Hash(Symbol, String | Symbol)) #

Allow to specify an order by hash with symbol keys.

Contact.all.order({:name => :asc})

[View source]
def order(opt : OrderExpression) #

Allow to specify an order by OrderExpression.

Contact.all.order(Contact._name.asc)

[View source]
def order(opts : Array(OrderExpression)) #

Allow to specify an order by OrderExpression array.

Contact.all.order([Contact._name.asc])

[View source]
def order(opts : Hash(String | Symbol, String | Symbol)) #

[View source]
def order(**opts) #

Allow to specify an order by splatted named tuple.

Contact.all.order(name: :asc)

[View source]
def order(&) #

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.


[View source]
def ordered? #

Show whether order is specified.


[View source]
def reorder(opts : Hash(String, String | Symbol)) #

[View source]
def reorder(opts : Hash(Symbol, String | Symbol)) #

[View source]
def reorder(opt : OrderExpression) #

[View source]
def reorder(opts : Array(OrderExpression)) #

[View source]
def reorder(opts : Hash(String | Symbol, String | Symbol)) #

[View source]
def reorder(**opts) #

Replace an existing order with the newly specified.

Contact.all.order(name: :asc).reorder(age: :desc) # ORDER BY contacts.age DESC

[View source]
def reorder(&) #

[View source]