Type alias Filter<Schema>

Filter<Schema>: {
    [K in keyof NoId<Schema>]?: FilterExpr<NoId<Schema>[K]>
} & {
    $and?: Filter<Schema>[];
    $not?: Filter<Schema>;
    $or?: Filter<Schema>[];
    _id?: FilterExpr<IdOf<Schema>>;
} & {
    [key: string]: any;
}

Represents some filter operation for a given document schema.

If you want stricter type-checking and full auto-complete, see StrictFilter.

This is a more relaxed version of StrictFilter that doesn't type-check nested fields.

Type Parameters

Type declaration

Type declaration

  • [key: string]: any

Example

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

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

See

StrictFilter