@atlantjs/backend 4.0.3 → 4.0.5

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.
@@ -11,7 +11,7 @@ export declare abstract class DatabaseHelperAbstract {
11
11
  read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(schema: T, condition: {
12
12
  [K in keyof InstanceType<T>]?: InstanceType<T>[K];
13
13
  }, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureAbstract>>;
14
- write<T extends Newable<ObjectLiteral>>(schema: T, sortedEntities: EntityAbstract[]): Promise<Return<undefined, undefined>>;
14
+ write<T extends Newable<ObjectLiteral>>(schema: T, entity: EntityAbstract): Promise<Return<undefined, undefined>>;
15
15
  delete<T extends Newable<ObjectLiteral>>(entity: T, condition: {
16
16
  [K in keyof InstanceType<T>]?: InstanceType<T>[K];
17
17
  }): Promise<Return<undefined, undefined>>;
@@ -31,24 +31,22 @@ class DatabaseHelperAbstract {
31
31
  })));
32
32
  return (0, arch_1.Success)(registryPacked);
33
33
  }
34
- async write(schema, sortedEntities) {
34
+ async write(schema, entity) {
35
35
  try {
36
36
  const client = await this.openTransaction();
37
37
  const repository = client.getRepository(schema);
38
- for (const sortedEntity of sortedEntities) {
39
- if (arch_1._.isUndefined(sortedEntity.toSchema) ||
40
- arch_1._.isUndefined(sortedEntity.id)) {
41
- return (0, arch_1.Failure)();
42
- }
43
- const registryPacked = (0, arch_1.Optional)(await repository.findOne({
44
- where: { id: sortedEntity.id.toString() },
45
- }));
46
- if (registryPacked.hasNothing()) {
47
- await repository.save(sortedEntity.toSchema());
48
- }
49
- else {
50
- await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toSchema());
51
- }
38
+ if (arch_1._.isUndefined(entity.toSchema) ||
39
+ arch_1._.isUndefined(entity.id)) {
40
+ return (0, arch_1.Failure)();
41
+ }
42
+ const registryPacked = (0, arch_1.Optional)(await repository.findOne({
43
+ where: { id: entity.id.toString() },
44
+ }));
45
+ if (registryPacked.hasNothing()) {
46
+ await repository.save(entity.toSchema());
47
+ }
48
+ else {
49
+ await repository.update({ id: entity.id.toString() }, entity.toSchema());
52
50
  }
53
51
  await this.commit();
54
52
  return (0, arch_1.Success)();
@@ -5,5 +5,5 @@ export declare abstract class EntityAbstract extends SolidAbstract {
5
5
  protected _id: UuidAbstract;
6
6
  constructor(_id: UuidAbstract);
7
7
  abstract get id(): UuidAbstract;
8
- abstract toSchema(): SchemaAbstract;
8
+ abstract toSchema(...args: unknown[]): SchemaAbstract;
9
9
  }
@@ -1,8 +1,4 @@
1
1
  import { EntityAbstract } from "../../../domain/entities/entity.abstract";
2
2
  export declare abstract class SchemaAbstract {
3
- protected _entity: EntityAbstract;
4
- protected _updatedAt: Date;
5
- protected _createdAt?: Date | undefined;
6
- constructor(_entity: EntityAbstract, _updatedAt: Date, _createdAt?: Date | undefined);
7
3
  abstract toSolid(): EntityAbstract;
8
4
  }
@@ -2,10 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaAbstract = void 0;
4
4
  class SchemaAbstract {
5
- constructor(_entity, _updatedAt, _createdAt) {
6
- this._entity = _entity;
7
- this._updatedAt = _updatedAt;
8
- this._createdAt = _createdAt;
9
- }
10
5
  }
11
6
  exports.SchemaAbstract = SchemaAbstract;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlantjs/backend",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "main": "index.js",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -53,7 +53,6 @@
53
53
  "copyfiles": "2.4.1",
54
54
  "cross-env": "7.0.3",
55
55
  "npm-check-updates": "17.1.15",
56
- "ts-jest": "29.2.6",
57
56
  "ts-node": "10.9.2",
58
57
  "ts-node-dev": "2.0.0",
59
58
  "ts-prune": "0.10.3",