@cbnsndwch/zero-sources

match() function

Home > @cbnsndwch/zero-contracts > match

match() function

Creates a $match pipeline stage for filtering documents.

This is equivalent to MongoDB's $match aggregation operator.

Signature:

declare function match<T>(filter: Filter<T>): MatchStage<T>;

Parameters

Parameter

Type

Description

filter

Filter<T>

MongoDB filter criteria

Returns:

MatchStage<T>

A $match stage

Example

const stage = match({ bundle: 'ENTERPRISE', isActive: true });
// { $match: { bundle: 'ENTERPRISE', isActive: true } }

const nestedStage = match({ 'members.role': { $in: ['admin', 'owner'] } });
// { $match: { 'members.role': { $in: ['admin', 'owner'] } } }

How was this page?