xcally-nest-library 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,13 +17,11 @@ class GenericRepository {
|
|
17
17
|
return this.repository.save(res);
|
18
18
|
}
|
19
19
|
async update(dto) {
|
20
|
-
const
|
21
|
-
|
22
|
-
});
|
23
|
-
if (!entity) {
|
20
|
+
const entityUpdated = await this.repository.update(dto.id, dto);
|
21
|
+
if (!entityUpdated.affected) {
|
24
22
|
throw new Error('Entity not found');
|
25
23
|
}
|
26
|
-
return this.repository.
|
24
|
+
return this.repository.findOneBy({ id: (0, typeorm_1.Equal)(dto.id) });
|
27
25
|
}
|
28
26
|
count(options) {
|
29
27
|
return this.repository.count(options);
|
@@ -34,10 +32,14 @@ class GenericRepository {
|
|
34
32
|
countAll() {
|
35
33
|
return this.repository.count();
|
36
34
|
}
|
37
|
-
findById(id) {
|
38
|
-
|
35
|
+
async findById(id) {
|
36
|
+
const entity = await this.repository.findOneBy({
|
39
37
|
id: (0, typeorm_1.Equal)(id),
|
40
38
|
});
|
39
|
+
if (!entity) {
|
40
|
+
throw new Error('Entity not found');
|
41
|
+
}
|
42
|
+
return entity;
|
41
43
|
}
|
42
44
|
}
|
43
45
|
exports.GenericRepository = GenericRepository;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generic.repository.js","sourceRoot":"","sources":["../../../../src/db/typeorm/generic.repository.ts"],"names":[],"mappings":";;;AAAA,qCAAuH;AACvH,qDAAqF;AASrF,MAAa,iBAAiB;IAI5B,YACmB,aAA4B,EAC7C,MAAuB,EACvB,cAAiC;QAFhB,kBAAa,GAAb,aAAa,CAAe;QAI7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAOD,OAAO,CAAC,KAAoB;QAC1B,OAAO,IAAA,0BAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE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