From b5fb8a72e33c101295450b32052189ad761dc526 Mon Sep 17 00:00:00 2001 From: "idan.d" Date: Mon, 20 Aug 2018 18:22:44 +0300 Subject: [PATCH 1/3] added replaceRoot method from Aggregate prototype --- types/mongoose/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 90bb04747f..9ac2895603 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -2409,6 +2409,13 @@ declare module "mongoose" { */ read(pref: string, tags?: any[]): this; + /** + * Appends a new $replaceRoot operator to this aggregate pipeline. + * Note that the $replaceRoot operator requires field strings to start with '$'. If you are passing in a string Mongoose will prepend '$' if the specified field doesn't start '$'. If you are passing in an object the strings in your expression will not be altered. + * @param newRoot field or document which will become the new root document + */ + replaceRoot(newRoot: string | object): this; + /** * Appends new custom $sample operator(s) to this aggregate pipeline. * @param size number of random documents to pick From 04b33c1233b0daef2798c36c633ac663c0149eae Mon Sep 17 00:00:00 2001 From: "idan.d" Date: Mon, 20 Aug 2018 18:26:58 +0300 Subject: [PATCH 2/3] added tests for replaceRoot --- types/mongoose/mongoose-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 02227c681d..da5aa792d8 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -1264,6 +1264,8 @@ aggregate.project({ }) aggregate.project({ salary_k: { $divide: [ "$salary", 1000 ]}}); aggregate.read('primaryPreferred').read('pp'); +aggregate.replaceRoot("user"); +aggregate.replaceRoot({x: {$concat: ['$this', '$that']}}); aggregate.sample(3).sample(3); aggregate.skip(10).skip(10); aggregate.sort({ field: 'asc', test: -1 }); From ab207c40c8759e11e1a3465e2668bda0c21cbedd Mon Sep 17 00:00:00 2001 From: "idan.d" Date: Mon, 20 Aug 2018 18:27:52 +0300 Subject: [PATCH 3/3] bump mongoose ver --- types/mongoose/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 9ac2895603..316887ac9c 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mongoose 5.2.2 +// Type definitions for Mongoose 5.2.3 // Project: http://mongoosejs.com/ // Definitions by: horiuchi // sindrenm