File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -762,6 +762,11 @@ if (limit) {
762
762
pipeline .push ({' $group' : {' _id' : 1 , ' n' : {' $sum' : 1 }}})
763
763
` ` `
764
764
765
+ Due to countDocuments using the ` $match ` aggregation pipeline stage, certain query operators cannot be used in
766
+ countDocuments. This includes the ` $where ` and ` $near ` query operators, among others. Drivers MUST document these
767
+ [restrictions](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/#restrictions) in their
768
+ documentation.
769
+
765
770
The count of documents is returned in the ` n ` field, similar to the ` count ` command. countDocuments options other than
766
771
filter, skip, and limit are added as options to the ` aggregate ` command.
767
772
@@ -2474,6 +2479,8 @@ aforementioned allowance in the SemVer spec.
2474
2479
2475
2480
## Changelog
2476
2481
2482
+ - 2024-10-30: Document query limitations in ` countDocuments ` .
2483
+
2477
2484
- 2024-10-01: Add sort option to ` replaceOne ` and ` updateOne ` .
2478
2485
2479
2486
- 2024-09-12: Specify that explain helpers support maxTimeMS.
You can’t perform that action at this time.
0 commit comments