diff --git a/api/src/chat/repositories/subscriber.repository.ts b/api/src/chat/repositories/subscriber.repository.ts index f6eb4d57..23d375ef 100644 --- a/api/src/chat/repositories/subscriber.repository.ts +++ b/api/src/chat/repositories/subscriber.repository.ts @@ -139,7 +139,7 @@ export class SubscriberRepository extends BaseRepository< * @returns The found subscriber entity with populated fields. */ async findOneByForeignIdAndPopulate(id: string): Promise { - const query = this.findByForeignIdQuery(id).populate(this.populate); + const query = this.findByForeignIdQuery(id).populate(this.populatePaths); const [result] = await this.execute(query, SubscriberFull); return result; } diff --git a/api/src/utils/generics/base-repository.ts b/api/src/utils/generics/base-repository.ts index ccfabb09..9244d13c 100644 --- a/api/src/utils/generics/base-repository.ts +++ b/api/src/utils/generics/base-repository.ts @@ -94,14 +94,14 @@ export abstract class BaseRepository< constructor( readonly model: Model, private readonly cls: new () => T, - protected readonly populate: P[] = [], + protected readonly populatePaths: P[] = [], protected readonly clsPopulate?: new () => TFull, ) { this.registerLifeCycleHooks(); } canPopulate(populate: string[]): boolean { - return populate.some((p) => this.populate.includes(p as P)); + return populate.some((p) => this.populatePaths.includes(p as P)); } getEventName(suffix: EHook) { @@ -303,7 +303,7 @@ export abstract class BaseRepository< ): Promise { this.ensureCanPopulate(); const query = this.findOneQuery(criteria, projection).populate( - this.populate, + this.populatePaths, ); return await this.executeOne(query, this.clsPopulate!); } @@ -375,7 +375,7 @@ export abstract class BaseRepository< } private ensureCanPopulate(): void { - if (!this.populate || !this.clsPopulate) { + if (!this.populatePaths || !this.clsPopulate) { throw new Error('Cannot populate query'); } } @@ -403,13 +403,13 @@ export abstract class BaseRepository< this.ensureCanPopulate(); if (Array.isArray(pageQuery)) { const query = this.findQuery(filters, pageQuery, projection).populate( - this.populate, + this.populatePaths, ); return await this.execute(query, this.clsPopulate!); } const query = this.findQuery(filters, pageQuery, projection).populate( - this.populate, + this.populatePaths, ); return await this.execute(query, this.clsPopulate!); } @@ -426,7 +426,7 @@ export abstract class BaseRepository< async findAllAndPopulate(sort?: QuerySortDto): Promise { this.ensureCanPopulate(); - const query = this.findAllQuery(sort).populate(this.populate); + const query = this.findAllQuery(sort).populate(this.populatePaths); return await this.execute(query, this.clsPopulate!); } @@ -463,7 +463,7 @@ export abstract class BaseRepository< ): Promise { this.ensureCanPopulate(); const query = this.findPageQuery(filters, pageQuery).populate( - this.populate, + this.populatePaths, ); return await this.execute(query, this.clsPopulate!); }