xcally-nest-library 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -50,7 +50,7 @@ export class GenericRepository<E extends ObjectLiteral> {
|
|
50
50
|
async update<T extends DeepPartial<E> & IId>(dto: T): Promise<E> {
|
51
51
|
const entityUpdated = await this.repository.update(dto.id, dto as any);
|
52
52
|
if (!entityUpdated.affected) {
|
53
|
-
|
53
|
+
return undefined;
|
54
54
|
}
|
55
55
|
return this.repository.findOneBy({ id: Equal(dto.id) } as unknown as FindOptionsWhere<E>);
|
56
56
|
}
|
@@ -83,9 +83,19 @@ export class GenericRepository<E extends ObjectLiteral> {
|
|
83
83
|
return this.repository.count();
|
84
84
|
}
|
85
85
|
|
86
|
-
|
87
|
-
|
86
|
+
/**
|
87
|
+
* Retrieves an entity from the database based on its ID.
|
88
|
+
*
|
89
|
+
* @param id - The ID of the entity to retrieve.
|
90
|
+
* @returns A promise that resolves to the retrieved entity.
|
91
|
+
*/
|
92
|
+
async findById(id: number): Promise<E> {
|
93
|
+
const entity = await this.repository.findOneBy({
|
88
94
|
id: Equal(id),
|
89
95
|
} as unknown as FindOptionsWhere<E>);
|
96
|
+
if (!entity) {
|
97
|
+
throw undefined;
|
98
|
+
}
|
99
|
+
return entity;
|
90
100
|
}
|
91
101
|
}
|