2

When I generate a model with loopback cli (lb4 model) I get a model with some properties. I am specifically trying to make a setter to hash a user entity password.

Initially, I get the following code :

@property({
  type: 'string',
  required: true,
})
password: string;

I want to know if I can change the code to this :

@property({
  type: 'string',
  required: true,
})
private _password: string;

set password(password: string) {
  this._password = Password.hash(password);
}
Emilio Numazaki
  • 836
  • 1
  • 5
  • 25
Léo Coletta
  • 1,099
  • 2
  • 12
  • 24

0 Answers0