Skip to content

Commit d8d8246

Browse files
types: make PipelineStage generic to fix QueryFilter incompatibility
1 parent 70b5a30 commit d8d8246

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

types/models.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ declare module 'mongoose' {
303303
SessionStarter {
304304
new <DocType = Partial<TRawDocType>>(doc?: DocType, fields?: any | null, options?: AnyObject): THydratedDocumentType;
305305

306-
aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate<Array<R>>;
307-
aggregate<R = any>(pipeline: PipelineStage[]): Aggregate<Array<R>>;
306+
aggregate<R = any>(pipeline?: PipelineStage<TRawDocType>[], options?: AggregateOptions): Aggregate<Array<R>>;
307+
aggregate<R = any>(pipeline: PipelineStage<TRawDocType>[]): Aggregate<Array<R>>;
308308

309309
/** Base Mongoose instance the model uses. */
310310
base: Mongoose;

types/pipelinestage.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare module 'mongoose' {
22
/**
33
* [Stages reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/#aggregation-pipeline-stages)
44
*/
5-
export type PipelineStage =
5+
export type PipelineStage<TSchema = any> =
66
| PipelineStage.AddFields
77
| PipelineStage.Bucket
88
| PipelineStage.BucketAuto
@@ -19,7 +19,7 @@ declare module 'mongoose' {
1919
| PipelineStage.Limit
2020
| PipelineStage.ListSessions
2121
| PipelineStage.Lookup
22-
| PipelineStage.Match
22+
| PipelineStage.Match<TSchema>
2323
| PipelineStage.Merge
2424
| PipelineStage.Out
2525
| PipelineStage.PlanCacheStats
@@ -114,7 +114,7 @@ declare module 'mongoose' {
114114
$facet: Record<string, FacetPipelineStage[]>;
115115
}
116116

117-
export type FacetPipelineStage = Exclude<PipelineStage, PipelineStage.CollStats | PipelineStage.Facet | PipelineStage.GeoNear | PipelineStage.IndexStats | PipelineStage.Out | PipelineStage.Merge | PipelineStage.PlanCacheStats>;
117+
export type FacetPipelineStage<TSchema=any> = Exclude<PipelineStage<TSchema>, PipelineStage.CollStats | PipelineStage.Facet | PipelineStage.GeoNear | PipelineStage.IndexStats | PipelineStage.Out | PipelineStage.Merge | PipelineStage.PlanCacheStats>;
118118

119119
export interface GeoNear {
120120
/** [`$geoNear` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/) */
@@ -182,9 +182,9 @@ declare module 'mongoose' {
182182
}
183183
}
184184

185-
export interface Match {
185+
export interface Match<TSchema = any> {
186186
/** [`$match` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/) */
187-
$match: QueryFilter<any>;
187+
$match: QueryFilter<TSchema>;
188188
}
189189

190190
export interface Merge {

0 commit comments

Comments
 (0)