Type alias CollectionFilter<Schema>

CollectionFilter<Schema>: {
    [K in keyof ToDotNotation<NoId<Schema>>]?: CollectionFilterExpr<ToDotNotation<NoId<Schema>>[K]>
} & {
    $and?: CollectionFilter<Schema>[];
    $not?: CollectionFilter<Schema>;
    $or?: CollectionFilter<Schema>[];
    _id?: CollectionFilterExpr<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 StrictCollectionFilter.

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

Type Parameters

Type declaration

Example

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

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