framework-do-dede 1.0.19 → 1.0.20
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.
- package/dist/domain/Entity.d.ts +4 -3
- package/dist/domain/Entity.js +6 -4
- package/package.json +1 -1
package/dist/domain/Entity.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare abstract class Entity {
|
|
2
|
-
|
|
3
|
-
toSave(): Record<string, any
|
|
4
|
-
protected beforeSave(): void
|
|
2
|
+
get(): Promise<Record<string, any>>;
|
|
3
|
+
toSave(): Promise<Record<string, any>>;
|
|
4
|
+
protected beforeSave(): Promise<void>;
|
|
5
|
+
protected beforeGet(): Promise<void>;
|
|
5
6
|
}
|
package/dist/domain/Entity.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export class Entity {
|
|
2
|
-
|
|
2
|
+
async get() {
|
|
3
3
|
const ctor = this.constructor;
|
|
4
4
|
const restrictedProps = ctor._restrictedProperties || new Set();
|
|
5
5
|
const exposedProps = ctor._exposedProperties || new Map();
|
|
6
6
|
const attributes = {};
|
|
7
|
+
await this.beforeGet();
|
|
7
8
|
for (const [key, value] of Object.entries(this)) {
|
|
8
9
|
if (!restrictedProps.has(key)) {
|
|
9
10
|
attributes[key] = value;
|
|
@@ -18,8 +19,8 @@ export class Entity {
|
|
|
18
19
|
}
|
|
19
20
|
return attributes;
|
|
20
21
|
}
|
|
21
|
-
toSave() {
|
|
22
|
-
this.beforeSave();
|
|
22
|
+
async toSave() {
|
|
23
|
+
await this.beforeSave();
|
|
23
24
|
const result = {};
|
|
24
25
|
const processedKeys = new Set();
|
|
25
26
|
const dbColumns = this.constructor._dbColumns;
|
|
@@ -49,5 +50,6 @@ export class Entity {
|
|
|
49
50
|
}
|
|
50
51
|
return result;
|
|
51
52
|
}
|
|
52
|
-
beforeSave() { }
|
|
53
|
+
async beforeSave() { }
|
|
54
|
+
async beforeGet() { }
|
|
53
55
|
}
|