Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #9680 from orgads/aggregate
Browse files Browse the repository at this point in the history
fix(index.d.ts): Fix return type of Model#aggregate()
  • Loading branch information
vkarpov15 committed Dec 8, 2020
2 parents 1ef8274 + 067e3a2 commit 8a52485
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Expand Up @@ -578,8 +578,8 @@ declare module "mongoose" {
interface Model<T extends Document> extends NodeJS.EventEmitter {
new(doc?: any): T;

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

/** Base Mongoose instance the model uses. */
base: typeof mongoose;
Expand Down
2 changes: 2 additions & 0 deletions test/typescript/models.ts
Expand Up @@ -21,3 +21,5 @@ const ExpiresSchema = new Schema({
expires: 3600,
},
});

const aggregated: Promise<Document> = Test.aggregate([]).then(res => res[0]);

0 comments on commit 8a52485

Please sign in to comment.