Aggregation task - $match
A scope aggregation task that filters documents that match the specified condition.
You can specify a filter to select a subset of documents.
Filtering uses logical and comparison operators just as individual
queries do.
Example
To select all documents from the furniture collection with type table, run the following command:
db.furniture.aggregate({$match: {"$eq": {{"type": "table"}}})
The $eq
operator
is the default match operator and does not need to be included in
the syntax. The following command is an example of a simplified syntax
that automatically uses the $eq
operator and returns
the same documents as the previous example:
db.furniture.aggregate({$match: {"type": "table"}})