-
Type: New Feature
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
The aggregation builder includes a builder for queries used in $match that can also be used to construct queries for non-aggregation contexts, such as MongoDB\Collection::find(), MongoDB\Collection::delete(), or MongoDB\Collection::update(). With the encoder option set on the client/database/collection object, these queries can be converted to BSON query objects that the server understands.
The builder supports functionality not supported in $match (such as $near or $where), making this a full-fledged builder for all methods that take a filter option. While $match would also accept those operators (which then would cause a server error when running the pipeline), creating separate types for queries and the $match operator is not feasible, as it requires duplication of all query operators. This would also prevent reusability of query objects in methods that take a filter and $match stages in pipelines.