Skip to content
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

DRIVERS-2728: Document query limitations in countDocuments API #1701

Merged
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
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
Loading