Facet function for mongoose aggregate

This commit is contained in:
Alexandr Ni
2018-08-31 17:25:46 -04:00
parent b18df829ac
commit 30661bcb49
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -2336,13 +2336,19 @@ declare module "mongoose" {
*/
cursor(options: any): this;
/**
* Appends a new $facet operator to this aggregate pipeline.
* @param arg $facet operator contents
*/
facet(arg: any): this;
// If cursor option is on, could return an object
/** Executes the aggregate pipeline on the currently bound Model. */
exec(callback?: (err: any, result: T) => void): Promise<T> | any;
/** Execute the aggregation with explain */
explain(callback?: (err: any, result: T) => void): Promise<T>;
/**
* Appends a new custom $group operator to this aggregate pipeline.
* @param arg $group operator contents
+1
View File
@@ -1227,6 +1227,7 @@ aggregate.append({ $project: { field: 1 }}, { $limit: 2 });
aggregate.append([{ $match: { daw: 'Logic Audio X' }} ]);
aggregate.collation({ locale: 'en_US', strength: 1 });
aggregate.count('countName');
aggregate.facet({ fieldA: [{ a: 1 }], fieldB: [{ b: 1 }] });
aggregate.cursor({ batchSize: 1000 }).exec().each(cb);
aggregate.exec().then(cb).catch(cb);
aggregate.option({foo: 'bar'}).exec();