$match

An aggregation pipeline stage that filters documents to pass only those matching the specified condition(s).

Syntax

mongodb
{ $match: { field: value } }

Example

mongodb
db.orders.aggregate([
  { $match: {
    status: "shipped",
    amount: { $gt: 100 },
    createdAt: { $gte: ISODate("2024-01-01") }
  }},
  { $count: "total" }
])