Skip to content

DOCS-1399 aggregate helper method throws exception upon error #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/core/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ The aggregation operation in the previous section returns a

- ``result`` which holds an array of documents returned by the :term:`pipeline`

- ``ok`` which holds the value ``1``, indicating success, or another value
if there was an error
- ``ok`` which holds the value ``1``, indicating success.

.. include:: /includes/fact-agg-helper-exception.rst

As a document, the result is subject to the :ref:`BSON
Document size <limit-bson-document-size>` limit, which is currently 16 megabytes.
Expand Down
5 changes: 5 additions & 0 deletions source/includes/fact-agg-helper-exception.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. versionchanged:: 2.4
If an error occurs, the :method:`~db.collection.aggregate()` helper
throws an exception. In previous versions, the helper returned a
document with the error message and code, and ``ok`` status field
not equal to ``1``, same as the :dbcommand:`aggregate` command.
2 changes: 2 additions & 0 deletions source/reference/command/aggregate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ aggregate
} }
);

.. include:: /includes/fact-agg-helper-exception.rst

For more aggregation documentation, please see:

- :doc:`/core/aggregation`
Expand Down
12 changes: 11 additions & 1 deletion source/reference/method/db.collection.aggregate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ db.collection.aggregate()

.. method:: db.collection.aggregate(pipeline)

.. versionadded:: 2.1.0
.. versionadded:: 2.2

Always call the :method:`db.collection.aggregate()` method on a collection
object.
Expand All @@ -16,6 +16,16 @@ db.collection.aggregate()
</reference/aggregation>` for documentation of
these operators.

:returns: A document with two fields:

- ``result`` which holds an array of documents returned by
the :term:`pipeline`

- ``ok`` which holds the value ``1``, indicating success.

:throws exception:
.. include:: /includes/fact-agg-helper-exception.rst

Consider the following example from the :doc:`aggregation
documentation </core/aggregation>`.

Expand Down