From b5b797566f9693655b9ffeb5a8e4e10838dc3083 Mon Sep 17 00:00:00 2001 From: kay Date: Mon, 15 Apr 2013 18:55:49 -0400 Subject: [PATCH] DOCS-1399 aggregate helper method throws exception upon error --- source/core/aggregation.txt | 5 +++-- source/includes/fact-agg-helper-exception.rst | 5 +++++ source/reference/command/aggregate.txt | 2 ++ source/reference/method/db.collection.aggregate.txt | 12 +++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 source/includes/fact-agg-helper-exception.rst diff --git a/source/core/aggregation.txt b/source/core/aggregation.txt index eca00589112..6536da0122b 100644 --- a/source/core/aggregation.txt +++ b/source/core/aggregation.txt @@ -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, which is currently 16 megabytes. diff --git a/source/includes/fact-agg-helper-exception.rst b/source/includes/fact-agg-helper-exception.rst new file mode 100644 index 00000000000..03ed15925b8 --- /dev/null +++ b/source/includes/fact-agg-helper-exception.rst @@ -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. diff --git a/source/reference/command/aggregate.txt b/source/reference/command/aggregate.txt index 4201abc6b7a..8a26e808ce4 100644 --- a/source/reference/command/aggregate.txt +++ b/source/reference/command/aggregate.txt @@ -55,6 +55,8 @@ aggregate } } ); + .. include:: /includes/fact-agg-helper-exception.rst + For more aggregation documentation, please see: - :doc:`/core/aggregation` diff --git a/source/reference/method/db.collection.aggregate.txt b/source/reference/method/db.collection.aggregate.txt index b0f81e5f8fc..70175f33d67 100644 --- a/source/reference/method/db.collection.aggregate.txt +++ b/source/reference/method/db.collection.aggregate.txt @@ -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. @@ -16,6 +16,16 @@ db.collection.aggregate() ` 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 `.