From bc41f2e8f85bb151845062f02514751bfb3efbf5 Mon Sep 17 00:00:00 2001 From: Aditi Khare <106987683+aditi-khare-mongoDB@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:33:56 -0500 Subject: [PATCH] docs(NODE-6483): Add documentation for countDocuments $match operator (#4342) --- src/collection.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/collection.ts b/src/collection.ts index 50adfbca76..d7cdc12e8e 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -765,6 +765,9 @@ export class Collection { /** * Gets the number of documents matching the filter. * For a fast count of the total documents in a collection see {@link Collection#estimatedDocumentCount| estimatedDocumentCount}. + * + * Due to countDocuments using the $match aggregation pipeline stage, certain query operators cannot be used in countDocuments. This includes the $where and $near query operators, among others. Details can be found in the documentation for the $match aggregation pipeline stage. + * * **Note**: When migrating from {@link Collection#count| count} to {@link Collection#countDocuments| countDocuments} * the following query operators must be replaced: *