lib/mongo/collection/view/readable.rb in mongo-2.16.4 vs lib/mongo/collection/view/readable.rb in mongo-2.17.0

- old
+ new

@@ -32,10 +32,29 @@ # ]) # # @param [ Array<Hash> ] pipeline The aggregation pipeline. # @param [ Hash ] options The aggregation options. # + # @option options [ true, false ] :allow_disk_use Set to true if disk + # usage is allowed during the aggregation. + # @option options [ Integer ] :batch_size The number of documents to return + # per batch. + # @option options [ true, false ] :bypass_document_validation Whether or + # not to skip document level validation. + # @option options [ Hash ] :collation The collation to use. + # @option options [ String ] :comment Associate a comment with the aggregation. + # @option options [ String ] :hint The index to use for the aggregation. + # @option options [ Hash ] :let Mapping of variables to use in the pipeline. + # See the server documentation for details. + # @option options [ Integer ] :max_time_ms The maximum amount of time in + # milliseconds to allow the aggregation to run. + # @option options [ true, false ] :use_cursor Indicates whether the command + # will request that the server provide results using a cursor. Note that + # as of server version 3.6, aggregations always provide results using a + # cursor and this option is therefore not valid. + # @option options [ Session ] :session The session to use. + # # @return [ Aggregation ] The aggregation object. # # @since 2.0.0 def aggregate(pipeline, options = {}) aggregation = Aggregation.new(self, pipeline, options) @@ -240,10 +259,14 @@ if server.description.server_version_gte?('5.0') pipeline = [ {'$collStats' => {'count' => {}}}, {'$group' => {'_id' => 1, 'n' => {'$sum' => '$count'}}}, ] - spec = Builder::Aggregation.new(pipeline, self, options.merge(session: session)).specification + spec = Builder::Aggregation.new( + pipeline, + self, + options.merge(session: session) + ).specification result = Operation::Aggregate.new(spec).execute(server, context: context) result.documents.first.fetch('n') else cmd = { count: collection.name } cmd[:maxTimeMS] = opts[:max_time_ms] if opts[:max_time_ms]