Skip to content

PipelineStage.Match does not allow specifying a type on QueryFilter<any> #15779

@sspenst

Description

@sspenst

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Upgrading to v9 and the following snippet gives a type error:

  const matchCondition: QueryFilter<Job> = {};

  if (isComplete) {
    matchCondition.completedAt = { $exists: true };
  } else {
    matchCondition.completedAt = { $exists: false };
  }

  const jobs = await JobModel.aggregate<Job>([
    { $match: matchCondition },
  ]);

The matchCondition here has to be a QueryFilter<any> type for this code to build, but I would like to be able to use my Job type here like I could in v8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions