@estgbue/mezgeb 0.0.52 → 0.0.53
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Repository, FindOptionsWhere, ObjectLiteral } from "typeorm";
|
|
2
|
-
export declare const safeSave: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>, patch:
|
|
3
|
-
export declare const safeRemove: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>) => Promise<T | undefined>;
|
|
1
|
+
import { Repository, FindOptionsWhere, ObjectLiteral, DeepPartial } from "typeorm";
|
|
2
|
+
export declare const safeSave: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>, patch: DeepPartial<T>) => Promise<T | T[] | undefined>;
|
|
3
|
+
export declare const safeRemove: <T extends ObjectLiteral>(repo: Repository<T>, conditions: FindOptionsWhere<T>) => Promise<T | T[] | undefined>;
|
|
4
4
|
//# sourceMappingURL=client-save-update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-save-update.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client-save-update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,
|
|
1
|
+
{"version":3,"file":"client-save-update.d.ts","sourceRoot":"","sources":["../../../libs/mezgeb/src/mezgeb/client/client-save-update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,QAAQ,GAAU,CAAC,SAAS,aAAa,EACpD,MAAM,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,gBAAgB,CAAC,CAAC,CAAC,EAC/B,OAAO,WAAW,CAAC,CAAC,CAAC,KACpB,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,GAAE,SAAS,CAU5B,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,CAAC,SAAS,aAAa,EACtD,MAAM,UAAU,CAAC,CAAC,CAAC,EACnB,YAAY,gBAAgB,CAAC,CAAC,CAAC,KAC9B,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAQ7B,CAAA"}
|
|
@@ -11,17 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.safeRemove = exports.safeSave = void 0;
|
|
13
13
|
const safeSave = (repo, conditions, patch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const entity = yield repo.
|
|
15
|
-
if (!entity) {
|
|
14
|
+
const entity = yield repo.findBy(conditions);
|
|
15
|
+
if (!entity || entity.length === 0) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
return repo.save(
|
|
18
|
+
const updatedEntities = entity.map(e => repo.merge(e, patch));
|
|
19
|
+
return repo.save(updatedEntities);
|
|
20
20
|
});
|
|
21
21
|
exports.safeSave = safeSave;
|
|
22
22
|
const safeRemove = (repo, conditions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const entity = yield repo.
|
|
24
|
-
if (!entity) {
|
|
23
|
+
const entity = yield repo.findBy(conditions);
|
|
24
|
+
if (!entity || entity.length === 0) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
return repo.remove(entity);
|