diff --git a/backend/src/libs/repositories/mongo/mongo-generic.repository.ts b/backend/src/libs/repositories/mongo/mongo-generic.repository.ts index c04dfd889..c8ddba71f 100644 --- a/backend/src/libs/repositories/mongo/mongo-generic.repository.ts +++ b/backend/src/libs/repositories/mongo/mongo-generic.repository.ts @@ -2,6 +2,8 @@ import { ClientSession, Model, PopulateOptions, UpdateQuery } from 'mongoose'; import { BaseInterfaceRepository } from '../interfaces/base.repository.interface'; import { ModelProps, SelectedValues } from '../types'; +type PopulateType = PopulateOptions | (PopulateOptions | string)[]; + export class MongoGenericRepository implements BaseInterfaceRepository { protected _repository: Model; protected _session: ClientSession; @@ -14,14 +16,11 @@ export class MongoGenericRepository implements BaseInterfaceRepository { return this._repository.countDocuments().lean().exec(); } - findAll( - selectedValues?: SelectedValues, - populate?: PopulateOptions | (PopulateOptions | string)[] - ): Promise { + findAll(selectedValues?: SelectedValues, populate?: PopulateType): Promise { return this._repository.find().select(selectedValues).populate(populate).exec(); } - findOneById(id: any, selectedValues?: SelectedValues, populate?: any): Promise { + findOneById(id: any, selectedValues?: SelectedValues, populate?: PopulateType): Promise { return this._repository .findById(id) .select(selectedValues) @@ -33,7 +32,11 @@ export class MongoGenericRepository implements BaseInterfaceRepository { return this._repository.findOne(value).exec(); } - findAllWithQuery(query: any, selectedValues?: SelectedValues, populate?: any): Promise { + findAllWithQuery( + query: any, + selectedValues?: SelectedValues, + populate?: PopulateType + ): Promise { return this._repository .find(query) .select(selectedValues) diff --git a/backend/src/modules/teams/services/create.team.service.ts b/backend/src/modules/teams/services/create.team.service.ts index 9a7811412..041f30d28 100644 --- a/backend/src/modules/teams/services/create.team.service.ts +++ b/backend/src/modules/teams/services/create.team.service.ts @@ -17,7 +17,7 @@ export default class CreateTeamService implements CreateTeamServiceInterface { private readonly teamUserRepository: TeamUserRepositoryInterface ) {} - async createTeamUsers(teamUsers: TeamUserDto[], teamId: string) { + createTeamUsers(teamUsers: TeamUserDto[], teamId: string) { return Promise.all( teamUsers.map((user) => this.teamUserRepository.create({ ...user, team: teamId })) );