Prerequisites
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.