Merge pull request #28240 from idandrd/master

Added replaceRoot method to Aggregate prototype
This commit is contained in:
Daniel Rosenwasser
2018-08-24 15:59:24 -07:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -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 <https://github.com/horiuchi>
// sindrenm <https://github.com/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
+2
View File
@@ -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 });