diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 90bb04747f..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 @@ -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 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 });