6 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 63
63
"rxjs" : " ^7.2.0" ,
64
64
"slonik" : " ^31.2.4" ,
65
65
"uuid" : " ^9.0.0" ,
66
- "zod" : " ^3.20.6 "
66
+ "zod" : " ^3.21.4 "
67
67
},
68
68
"devDependencies" : {
69
69
"@nestjs/cli" : " ^9.0.0" ,
108
108
"testEnvironment" : " node"
109
109
},
110
110
"volta" : {
111
- "node" : " 16.16 .0"
111
+ "node" : " 20.1 .0"
112
112
}
113
113
}
Original file line number Diff line number Diff line change @@ -92,21 +92,17 @@ export abstract class Entity<EntityProps> {
92
92
}
93
93
94
94
/**
95
- * Returns current **copy** of entity's props.
96
- * Modifying entity's state won't change previously created
97
- * copy returned by this method since it doesn't return a reference.
98
- * If a reference to a specific property is needed create a getter in parent class.
99
- *
95
+ * Returns entity properties.
100
96
* @return {* } {Props & EntityProps}
101
97
* @memberof Entity
102
98
*/
103
- public getPropsCopy ( ) : EntityProps & BaseEntityProps {
104
- const propsCopy = structuredClone ( {
99
+ public getProps ( ) : EntityProps & BaseEntityProps {
100
+ const propsCopy = {
105
101
id : this . _id ,
106
102
createdAt : this . _createdAt ,
107
103
updatedAt : this . _updatedAt ,
108
104
...this . props ,
109
- } ) ;
105
+ } ;
110
106
return Object . freeze ( propsCopy ) ;
111
107
}
112
108
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class UserRepository
49
49
}
50
50
51
51
async updateAddress ( user : UserEntity ) : Promise < void > {
52
- const address = user . getPropsCopy ( ) . address ;
52
+ const address = user . getProps ( ) . address ;
53
53
const statement = sql . type ( userSchema ) `
54
54
UPDATE "users" SET
55
55
street = ${ address . street } , country = ${ address . country } , "postalCode" = ${ address . postalCode }
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export class UserEntity extends AggregateRoot<UserProps> {
36
36
/* You can create getters only for the properties that you need to
37
37
access and leave the rest of the properties private to keep entity
38
38
encapsulated. To get all entity properties (for saving it to a
39
- database or mapping a response) use .getPropsCopy () method
39
+ database or mapping a response) use .getProps () method
40
40
defined in a EntityBase parent class */
41
41
get role ( ) : UserRoles {
42
42
return this . props . role ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class UserMapper
17
17
implements Mapper < UserEntity , UserModel , UserResponseDto >
18
18
{
19
19
toPersistence ( entity : UserEntity ) : UserModel {
20
- const copy = entity . getPropsCopy ( ) ;
20
+ const copy = entity . getProps ( ) ;
21
21
const record : UserModel = {
22
22
id : copy . id ,
23
23
createdAt : copy . createdAt ,
@@ -50,7 +50,7 @@ export class UserMapper
50
50
}
51
51
52
52
toResponse ( entity : UserEntity ) : UserResponseDto {
53
- const props = entity . getPropsCopy ( ) ;
53
+ const props = entity . getProps ( ) ;
54
54
const response = new UserResponseDto ( entity ) ;
55
55
response . email = props . email ;
56
56
response . country = props . address . country ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { WalletModel, walletSchema } from './database/wallet.repository';
6
6
@Injectable ( )
7
7
export class WalletMapper implements Mapper < WalletEntity , WalletModel > {
8
8
toPersistence ( entity : WalletEntity ) : WalletModel {
9
- const copy = entity . getPropsCopy ( ) ;
9
+ const copy = entity . getProps ( ) ;
10
10
const record : WalletModel = {
11
11
id : copy . id ,
12
12
createdAt : copy . createdAt ,
0 commit comments