xcally-nest-library 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcally-nest-library",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -62,6 +62,7 @@
62
62
  "eslint-plugin-prettier": "^5.1.3",
63
63
  "jest": "^29.7.0",
64
64
  "prettier": "^3.2.5",
65
+ "rimraf": "^5.0.5",
65
66
  "source-map-support": "^0.5.21",
66
67
  "supertest": "^6.3.4",
67
68
  "ts-jest": "^29.1.2",
@@ -48,13 +48,11 @@ export class GenericRepository<E extends ObjectLiteral> {
48
48
  * @throws Error if the entity is not found.
49
49
  */
50
50
  async update<T extends DeepPartial<E> & IId>(dto: T): Promise<E> {
51
- const entity = await this.repository.findOneBy({
52
- id: Equal(dto.id),
53
- } as unknown as FindOptionsWhere<E>);
54
- if (!entity) {
51
+ const entityUpdated = await this.repository.update(dto.id, dto as any);
52
+ if (!entityUpdated.affected) {
55
53
  throw new Error('Entity not found');
56
54
  }
57
- return this.repository.save({ id: entity.id, ...dto });
55
+ return this.repository.findOneBy({ id: Equal(dto.id) } as unknown as FindOptionsWhere<E>);
58
56
  }
59
57
 
60
58
  /**