xcally-nest-library 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -11,12 +11,13 @@ interface IId {
|
|
11
11
|
export class GenericRepository<E extends ObjectLiteral> {
|
12
12
|
protected repository: Repository<E>;
|
13
13
|
protected paginateConfig: PaginateConfig<E>;
|
14
|
+
|
14
15
|
constructor(
|
15
|
-
readonly entityManager: EntityManager,
|
16
|
+
private readonly entityManager: EntityManager,
|
16
17
|
entity: EntityTarget<E>,
|
17
18
|
paginateConfig: PaginateConfig<E>,
|
18
19
|
) {
|
19
|
-
this.repository = entityManager.getRepository(entity);
|
20
|
+
this.repository = this.entityManager.getRepository(entity);
|
20
21
|
this.paginateConfig = paginateConfig;
|
21
22
|
}
|
22
23
|
/**
|
@@ -83,4 +84,10 @@ export class GenericRepository<E extends ObjectLiteral> {
|
|
83
84
|
countAll(): Promise<number> {
|
84
85
|
return this.repository.count();
|
85
86
|
}
|
87
|
+
|
88
|
+
findById(id: number): Promise<E> {
|
89
|
+
return this.repository.findOneBy({
|
90
|
+
id: Equal(id),
|
91
|
+
} as unknown as FindOptionsWhere<E>);
|
92
|
+
}
|
86
93
|
}
|