lib/mongo/collection/view/builder/find_command.rb in mongo-2.4.3 vs lib/mongo/collection/view/builder/find_command.rb in mongo-2.5.0.beta
- old
+ new
@@ -46,11 +46,10 @@
tailable_cursor: 'tailable',
oplog_replay: 'oplogReplay',
no_cursor_timeout: 'noCursorTimeout',
await_data: 'awaitData',
allow_partial_results: 'allowPartialResults',
- read_concern: 'readConcern',
collation: 'collation'
).freeze
def_delegators :@view, :collection, :database, :filter, :options, :read
@@ -71,14 +70,16 @@
#
# @example Create the find command builder.
# FindCommandBuilder.new(view)
#
# @param [ Collection::View ] view The collection view.
+ # @param [ Session ] session The session.
#
# @since 2.2.2
- def initialize(view)
+ def initialize(view, session)
@view = view
+ @session = session
end
# Get the specification to pass to the find command operation.
#
# @example Get the specification.
@@ -86,16 +87,17 @@
#
# @return [ Hash ] The specification.
#
# @since 2.2.0
def specification
- { selector: find_command, db_name: database.name, read: read }
+ { selector: find_command, db_name: database.name, read: read, session: @session }
end
private
def find_command
document = BSON::Document.new('find' => collection.name, 'filter' => filter)
+ document[:readConcern] = collection.read_concern if collection.read_concern
command = Options::Mapper.transform_documents(convert_flags(options), MAPPINGS, document)
convert_limit_and_batch_size(command)
command
end