fix: unit tests

This commit is contained in:
Mohamed Marrouchi
2024-09-21 19:43:04 +01:00
parent 7bc5270551
commit 93bb9ee04f
21 changed files with 87 additions and 72 deletions

View File

@@ -161,9 +161,7 @@ export abstract class BaseRepository<
}
async findOneAndPopulate(criteria: string | TFilterQuery<T>) {
if (!this.populate || !this.clsPopulate) {
throw new Error('Cannot populate query');
}
this.ensureCanPopulate();
const query = this.findOneQuery(criteria).populate(this.populate);
return await this.executeOne(query, this.clsPopulate);
}

View File

@@ -10,8 +10,12 @@
import { BaseRepository } from './base-repository';
import { BaseSchema } from './base-schema';
export abstract class BaseSeeder<T, P extends string = never> {
constructor(protected readonly repository: BaseRepository<T, P>) {}
export abstract class BaseSeeder<
T,
P extends string = never,
TFull extends Omit<T, P> = never,
> {
constructor(protected readonly repository: BaseRepository<T, P, TFull>) {}
async findAll(): Promise<T[]> {
return await this.repository.findAll();