From 6a489ae39328f7037d3c18788251100c372edc88 Mon Sep 17 00:00:00 2001 From: Flamenco Date: Fri, 4 Feb 2022 12:48:10 -0500 Subject: [PATCH] Add clarification when no results exist before the $count stage. --- source/reference/operator/aggregation/count.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/reference/operator/aggregation/count.txt b/source/reference/operator/aggregation/count.txt index e7638c62b5f..ac77c38bb11 100644 --- a/source/reference/operator/aggregation/count.txt +++ b/source/reference/operator/aggregation/count.txt @@ -60,6 +60,8 @@ The :pipeline:`$count` stage is equivalent to the following where ``myCount`` would be the output field that contains the count. You can specify another name for the output field. +If the previous stage contains 0 documents, this stage will **NOT** return a single document with `{myCount: 0}`; It will return the result of 0 documents, and this stage will not be executed. + .. seealso:: :method:`db.collection.countDocuments()` which wraps the