============================== MongoDB\\Database::aggregate() ============================== .. versionadded:: 1.5 .. default-domain:: mongodb .. contents:: On this page :local: :backlinks: none :depth: 1 :class: singlecol Definition ---------- .. phpmethod:: MongoDB\\Database::aggregate() Runs a specified :manual:`admin/diagnostic pipeline ` which does not require an underlying collection. For aggregations on collection data, see :phpmethod:`MongoDB\\Collection::aggregate()`. .. code-block:: php function aggregate(array $pipeline, array $options = []): Traversable This method has the following parameters: .. include:: /includes/apiargs/MongoDBDatabase-method-aggregate-param.rst The ``$options`` parameter supports the following options: .. include:: /includes/apiargs/MongoDBDatabase-method-aggregate-option.rst Return Values ------------- A :php:`MongoDB\\Driver\\Cursor ` or :php:`ArrayIterator ` object. In both cases, the return value will be :php:`Traversable `. Errors/Exceptions ----------------- .. include:: /includes/extracts/error-unexpectedvalueexception.rst .. include:: /includes/extracts/error-unsupportedexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst .. _php-db-agg-method-behavior: .. todo: add examples See Also -------- - :phpmethod:`MongoDB\\Collection::aggregate()` - :manual:`aggregate ` command reference in the MongoDB manual - :manual:`Aggregation Pipeline ` documentation in the MongoDB Manual