xcally-nest-library 0.0.7 → 0.0.8
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
@@ -83,9 +83,20 @@ 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
|
+
* @throws Error if the entity is not found.
|
92
|
+
*/
|
93
|
+
async findById(id: number): Promise<E> {
|
94
|
+
const entity = await this.repository.findOneBy({
|
88
95
|
id: Equal(id),
|
89
96
|
} as unknown as FindOptionsWhere<E>);
|
97
|
+
if (!entity) {
|
98
|
+
throw new Error('Entity not found');
|
99
|
+
}
|
100
|
+
return entity;
|
90
101
|
}
|
91
102
|
}
|