Skip to content

Commit 8a52485

Browse files
authoredDec 8, 2020
Merge pull request #9680 from orgads/aggregate
fix(index.d.ts): Fix return type of Model#aggregate()
2 parents 1ef8274 + 067e3a2 commit 8a52485

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ declare module "mongoose" {
578578
interface Model<T extends Document> extends NodeJS.EventEmitter {
579579
new(doc?: any): T;
580580

581-
aggregate<R>(pipeline?: any[]): Aggregate<Array<R>>;
582-
aggregate<R>(pipeline: any[], cb: Function): Promise<Array<R>>;
581+
aggregate<R = any>(pipeline?: any[]): Aggregate<Array<R>>;
582+
aggregate<R = any>(pipeline: any[], cb: Function): Promise<Array<R>>;
583583

584584
/** Base Mongoose instance the model uses. */
585585
base: typeof mongoose;

‎test/typescript/models.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ const ExpiresSchema = new Schema({
2121
expires: 3600,
2222
},
2323
});
24+
25+
const aggregated: Promise<Document> = Test.aggregate([]).then(res => res[0]);

0 commit comments

Comments
 (0)
Please sign in to comment.