| Module | Origin::Optional |
| In: |
lib/origin/optional.rb
|
| options | [RW] | @attribute [rw] options The query options. |
Adds the option for telling MongoDB how many documents to retrieve in it‘s batching.
@example Apply the batch size options.
optional.batch_size(500)
@param [ Integer ] value The batch size.
@return [ Optional ] The cloned optional.
@since 1.0.0
Associate a comment with the query.
@example Add a comment.
optional.comment('slow query')
@note Set profilingLevel to 2 and the comment will be logged in the profile
collection along with the query.
@param [ String ] comment The comment to be associated with the query.
@return [ Optional ] The cloned optional.
@since 2.2.0
Set the cursor type.
@example Set the cursor type.
optional.cursor_type(:tailable) optional.cursor_type(:tailable_await)
@note The cursor can be type :tailable or :tailable_await.
@param [ Symbol ] type The type of cursor to create.
@return [ Optional ] The cloned optional.
@since 2.2.0
Add descending sorting options for all the provided fields.
@example Add descending sorting.
optional.descending(:first_name, :last_name)
@param [ Array<Symbol> ] fields The fields to sort.
@return [ Optional ] The cloned optional.
@since 1.0.0
Tell the query not to timeout.
@example Tell the query not to timeout.
optional.no_timeout
@return [ Optional ] The cloned optional.
@since 1.0.0
Adds sorting criterion to the options.
@example Add sorting options via a hash with integer directions.
optional.order_by(name: 1, dob: -1)
@example Add sorting options via a hash with symbol directions.
optional.order_by(name: :asc, dob: :desc)
@example Add sorting options via a hash with string directions.
optional.order_by(name: "asc", dob: "desc")
@example Add sorting options via an array with integer directions.
optional.order_by([[ name, 1 ], [ dob, -1 ]])
@example Add sorting options via an array with symbol directions.
optional.order_by([[ name, :asc ], [ dob, :desc ]])
@example Add sorting options via an array with string directions.
optional.order_by([[ name, "asc" ], [ dob, "desc" ]])
@example Add sorting options with keys.
optional.order_by(:name.asc, :dob.desc)
@example Add sorting options via a string.
optional.order_by("name ASC, dob DESC")
@param [ Array, Hash, String ] spec The sorting specification.
@return [ Optional ] The cloned optional.
@since 1.0.0