Skip to content

Commit

Permalink
DRIVERS-2728: Document query limitations in countDocuments API (#1701)
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus authored Oct 31, 2024
1 parent 5f6fd28 commit 121db8e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/crud/crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,11 @@ if (limit) {
pipeline.push({'$group': {'_id': 1, 'n': {'$sum': 1}}})
```
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. Drivers MUST document these
[restrictions](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#restrictions) in their
documentation.
The count of documents is returned in the `n` field, similar to the `count` command. countDocuments options other than
filter, skip, and limit are added as options to the `aggregate` command.
Expand Down Expand Up @@ -2474,6 +2479,8 @@ aforementioned allowance in the SemVer spec.
## Changelog
- 2024-10-30: Document query limitations in `countDocuments`.
- 2024-10-01: Add sort option to `replaceOne` and `updateOne`.
- 2024-09-12: Specify that explain helpers support maxTimeMS.
Expand Down

0 comments on commit 121db8e

Please sign in to comment.