The countDocuments CRUD operation supports the same options as the deprecated count operation. This includes hint, although the implementation of countDocuments means that it is provided to aggregate instead of count.
Looking at the implementation of mongoc_collection_count_documents, the "skip" and "limit" opts are used to create the aggregate command, and any other opts are passed as generic command options to mongoc_collection_read_command_with_opts. This bypasses the options handling that might typically occur in _mongoc_aggregate_opts_parse.
This apparently was not a problem for the comment option (CDRIVER-4199), which is provided as a bson_value_t; however, I think it may be problematic for the hint option as the functions will skip the typical validation we get through _mongoc_convert_hint.
Looking at this further, I realized that hint is not even defined for mongoc_aggregate_opts_t in generate-opts.py, so the aggregate operation is also missing documentation and validation.
- is related to
-
CDRIVER-4199 Add support for the comment field to all helpers
- Closed
- related to
-
DRIVERS-2320 Add spec tests for aggregate and countDocuments hint option
- Backlog