Type alias StrictFilter<Schema>

StrictFilter<Schema>: {
    [K in keyof ToDotNotation<NoId<Schema>>]?: FilterExpr<ToDotNotation<NoId<Schema>>[K]>
} & {
    $and?: StrictFilter<Schema>[];
    $not?: StrictFilter<Schema>;
    $or?: StrictFilter<Schema>[];
    _id?: FilterExpr<IdOf<Schema>>;
}

Represents some filter operation for a given document schema.

If you want relaxed type-checking, see Filter.

This is a stricter version of Filter that type-checks nested fields.

You can use it anywhere by using the satisfies keyword, or by creating a temporary const with the StrictFilter type.

Type Parameters

Type declaration

Example

interface BasicSchema {
  arr: string[],
  num: number,
}

db.collection<BasicSchema>('coll_name').findOne({
  $and: [
  { _id: { $in: ['abc', 'def'] } },
  { $not: { arr: { $size: 0 } } },
  ]
} satisfies StrictFilter<BasicSchema>);

See

Filter