RUBY-266 support maxscan, showDiskLoc, and returnKey

This commit is contained in:
Kyle Banker 2011-05-10 15:40:06 -04:00
parent 505bc68aab
commit 9a80fbaa66
2 changed files with 28 additions and 7 deletions

View File

@ -162,6 +162,9 @@ module Mongo
# never timeout. Note that disabling timeout will only work when #find is invoked with a block.
# This is to prevent any inadvertant failure to close the cursor, as the cursor is explicitly
# closed when block code finishes.
# @option opts [Integer] :max_scan (nil) Limit the number of items to scan on both collection scans and indexed queries..
# @option opts [Boolean] :show_disk_loc (false) Return the disk location of each query result (for debugging).
# @option opts [Boolean] :return_key (false) Return the index key used to obtain the result (for debugging).
# @option opts [Block] :transformer (nil) a block for tranforming returned documents.
# This is normally used by object mappers to convert each returned document to an instance of a class.
#

View File

@ -41,19 +41,31 @@ module Mongo
@connection = @db.connection
@logger = @connection.logger
# Query selector
@selector = opts[:selector] || {}
# Special operators that form part of $query
@order = opts[:order]
@explain = opts[:explain]
@hint = opts[:hint]
@snapshot = opts[:snapshot]
@max_scan = opts.fetch(:max_scan, nil)
@return_key = opts.fetch(:return_key, nil)
@show_disk_loc = opts.fetch(:show_disk_loc, nil)
# Wire-protocol settings
@fields = convert_fields_for_query(opts[:fields])
@skip = opts[:skip] || 0
@limit = opts[:limit] || 0
@order = opts[:order]
@hint = opts[:hint]
@snapshot = opts[:snapshot]
@timeout = opts.fetch(:timeout, true)
@explain = opts[:explain]
@socket = opts[:socket]
@tailable = opts[:tailable] || false
@timeout = opts.fetch(:timeout, true)
# Use this socket for the query
@socket = opts[:socket]
@closed = false
@query_run = false
@transformer = opts[:transformer]
batch_size(opts[:batch_size] || 0)
@ -320,7 +332,10 @@ module Mongo
:order => @order,
:hint => @hint,
:snapshot => @snapshot,
:timeout => @timeout }
:timeout => @timeout,
:max_scan => @max_scan,
:return_key => @return_key,
:show_disk_loc => @show_disk_loc }
end
# Clean output for inspect.
@ -429,6 +444,9 @@ module Mongo
spec['$hint'] = @hint if @hint && @hint.length > 0
spec['$explain'] = true if @explain
spec['$snapshot'] = true if @snapshot
spec['$maxscan'] = @max_scan if @max_scan
spec['$returnKey'] = true if @return_key
spec['$showDiskLoc'] = true if @show_disk_loc
spec
end