@atlantjs/arch 3.1.14 → 3.1.16

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.
@@ -35,17 +35,18 @@ class DatabaseHelperAbstract {
35
35
  const client = await this.openTransaction();
36
36
  const repository = client.getRepository(schema);
37
37
  sortedEntities.forEach(async (sortedEntity) => {
38
- const registryPacked = (0, optional_type_1.Optional)(await repository.findOne({
39
- where: { id: sortedEntity.id.toString() },
40
- }));
41
- if (guardian_1.Guardian.isUndefined(sortedEntity.toPersist)) {
38
+ if (guardian_1.Guardian.isUndefined(sortedEntity.toPersist) ||
39
+ guardian_1.Guardian.isUndefined(sortedEntity.getId)) {
42
40
  return (0, return_type_1.Failure)();
43
41
  }
42
+ const registryPacked = (0, optional_type_1.Optional)(await repository.findOne({
43
+ where: { id: sortedEntity.getId().toString() },
44
+ }));
44
45
  if (registryPacked.hasNothing()) {
45
46
  await repository.save(sortedEntity.toPersist());
46
47
  }
47
48
  else {
48
- await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toPersist());
49
+ await repository.update({ id: sortedEntity.getId().toString() }, sortedEntity.toPersist());
49
50
  }
50
51
  });
51
52
  await this.commit();
@@ -3,7 +3,7 @@ import { UuidAbstract } from "./uuid.abstract";
3
3
  export declare abstract class EntityAbstract extends SolidAbstract {
4
4
  protected _id?: UuidAbstract | undefined;
5
5
  constructor(_id?: UuidAbstract | undefined);
6
- abstract get id(): UuidAbstract;
6
+ abstract getId?(): UuidAbstract;
7
7
  private requireToPersist;
8
8
  abstract toPersist?(): EntityAbstract;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlantjs/arch",
3
- "version": "3.1.14",
3
+ "version": "3.1.16",
4
4
  "main": "index.js",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {