Method: Mongo::Database#aggregate
- Defined in:
- lib/mongo/database.rb
#aggregate(pipeline, options = {}) ⇒ Collection::View::Aggregation
Perform an aggregation on the database.
Examples:
Perform an aggregation.
Perform an aggregation.
collection.aggregate([ { "$listLocalSessions" => {} } ])
Parameters:
-
pipeline
(Array<Hash>)
—
The aggregation pipeline.
-
options
(Hash)
(defaults to: {})
—
The aggregation options.
Options Hash (options):
-
:allow_disk_use
(true, false)
—
Set to true if disk usage is allowed during the aggregation.
-
:batch_size
(Integer)
—
The number of documents to return per batch.
-
:bypass_document_validation
(true, false)
—
Whether or not to skip document level validation.
-
:collation
(Hash)
—
The collation to use.
-
:comment
(Object)
—
A user-provided comment to attach to this command.
-
:max_time_ms
(Integer)
—
The maximum amount of time to allow the query to run, in milliseconds. This option is deprecated, use :timeout_ms instead.
-
:timeout_ms
(Integer)
—
The operation timeout in milliseconds. Must be a non-negative integer. An explicit value of 0 means infinite. The default value is unset which means the value is inherited from the database or the client.
-
:hint
(String)
—
The index to use for the aggregation.
-
:session
(Session)
—
The session to use.
Returns:
-
(Collection::View::Aggregation)
—
The aggregation object.
Since:
-
2.10.0
457 458 459 |
# File 'lib/mongo/database.rb', line 457 def aggregate(pipeline, options = {}) View.new(self, options).aggregate(pipeline, options) end |