-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(test) : début ajout de feature pour l'aggréation dans l'API.
- Loading branch information
Showing
9 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import AbstractModel from "@core/Model"; | ||
|
||
|
||
export default class ServiceAggregate { | ||
// take the model - mongooseModel | ||
|
||
public model:AbstractModel; | ||
|
||
constructor(model:AbstractModel) { | ||
this.model = model; | ||
} | ||
|
||
public async lookupFor($query:any, $lookupQUery:any):Promise<any> { | ||
let aggregateArray:Array<any> = []; | ||
aggregateArray.push($query); | ||
aggregateArray.push($lookupQUery); | ||
return this.model.mongooseModel.aggregate([ | ||
{$match: $query}, | ||
{$lookup: $lookupQUery} | ||
]).exec(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
const withOrganiations = function() { | ||
this.aggregate([{ | ||
from: 'organisations', | ||
localField: '_id', | ||
foreignField: 'team.member', | ||
as: 'organisations' | ||
}]) | ||
} | ||
|
||
export default withOrganiations; |