@@ -165,6 +165,7 @@ def initialize(database, name, options = {})
165165 @database = database
166166 @name = name . to_s . freeze
167167 @options = options . dup
168+ @timeout_ms = options . delete ( :timeout_ms )
168169=begin WriteConcern object support
169170 if @options[:write_concern].is_a?(WriteConcern::Base)
170171 # Cache the instance so that we do not needlessly reconstruct it.
@@ -504,6 +505,9 @@ def drop(opts = {})
504505 # @option options [ Integer ] :skip The number of docs to skip before returning results.
505506 # @option options [ Hash ] :sort The key and direction pairs by which the result set
506507 # will be sorted.
508+ # @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
509+ # :timeout_ms (whether it applies to the lifetime of the cursor, or per
510+ # iteration).
507511 # @option options [ Integer ] :timeout_ms The per-operation timeout in milliseconds.
508512 # Must a positive integer. The default value is unset which means infinite.
509513 # @option options [ Hash ] :let Mapping of variables to use in the command.
@@ -538,10 +542,6 @@ def find(filter = nil, options = {})
538542 # See the server documentation for details.
539543 # @option options [ Integer ] :max_time_ms The maximum amount of time in
540544 # milliseconds to allow the aggregation to run.
541- # @option options [ true | false ] :use_cursor Indicates whether the command
542- # will request that the server provide results using a cursor. Note that
543- # as of server version 3.6, aggregations always provide results using a
544- # cursor and this option is therefore not valid.
545545 # @option options [ Session ] :session The session to use.
546546 # @option options [ Integer ] :timeout_ms The per-operation timeout in milliseconds.
547547 # Must a positive integer. The default value is unset which means infinite.
@@ -612,6 +612,11 @@ def aggregate(pipeline, options = {})
612612 # events included with this flag set are: createIndexes, dropIndexes,
613613 # modify, create, shardCollection, reshardCollection,
614614 # refineCollectionShardKey.
615+ # @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
616+ # :timeout_ms (whether it applies to the lifetime of the cursor, or per
617+ # iteration).
618+ # @option options [ Integer ] :timeout_ms The maximum amount of time to
619+ # allow the query to run, in milliseconds.
615620 #
616621 # @note A change stream only allows 'majority' read concern.
617622 # @note This helper method is preferable to running a raw aggregation with
@@ -622,7 +627,7 @@ def aggregate(pipeline, options = {})
622627 # @since 2.5.0
623628 def watch ( pipeline = [ ] , options = { } )
624629 view_options = options . dup
625- view_options [ :await_data ] = true if options [ :max_await_time_ms ]
630+ view_options [ :cursor_type ] = :tailable_await if options [ :max_await_time_ms ]
626631 View ::ChangeStream . new ( View . new ( self , { } , view_options ) , pipeline , nil , options )
627632 end
628633
@@ -966,12 +971,17 @@ def delete_many(filter = nil, options = {})
966971 # @option options [ Integer ] :max_time_ms The maximum amount of time to allow the command
967972 # to run in milliseconds.
968973 # @option options [ Session ] :session The session to use.
974+ # @option options [ :cursor_lifetime | :iteration ] :timeout_mode How to interpret
975+ # :timeout_ms (whether it applies to the lifetime of the cursor, or per
976+ # iteration).
977+ # @option options [ Integer ] :timeout_ms The maximum amount of time to
978+ # allow the query to run, in milliseconds.
969979 #
970980 # @return [ Array<Cursor> ] An array of cursors.
971981 #
972982 # @since 2.1
973983 def parallel_scan ( cursor_count , options = { } )
974- find ( { } , options ) . send ( : parallel_scan, cursor_count , options )
984+ find ( { } , options ) . parallel_scan ( cursor_count , options )
975985 end
976986
977987 # Replaces a single document in the collection with the new document.
@@ -1205,14 +1215,14 @@ def system_collection?
12051215 #
12061216 # @api private
12071217 def timeout_ms
1208- options [ : timeout_ms] || database . timeout_ms
1218+ @ timeout_ms || database . timeout_ms
12091219 end
12101220
12111221 # @return [ Hash ] timeout_ms value set on the operation level (if any),
12121222 # and/or timeout_ms that is set on collection/database/client level (if any).
12131223 #
12141224 # @api private
1215- def operation_timeouts ( opts )
1225+ def operation_timeouts ( opts = { } )
12161226 # TODO: We should re-evaluate if we need two timeouts separately.
12171227 { } . tap do |result |
12181228 if opts [ :timeout_ms ] . nil?
0 commit comments