Method: Mongoid::Criterion::Optional#order_by
- Defined in:
- lib/mongoid/criterion/optional.rb
#order_by(params = []) ⇒ Object
Adds a criterion to the Criteria
that specifies the sort order of the returned documents in the database. Similar to a SQL “ORDER BY”.
Options:
params: An Array
of [field, direction] sorting pairs.
Example:
criteria.order_by([[:field1, :asc], [:field2, :desc]])
Returns: self
113 114 115 |
# File 'lib/mongoid/criterion/optional.rb', line 113 def order_by(params = []) @options[:sort] = params; self end |