Open susatyo441 opened 8 months ago
I override toJSON
toJSON() {
const json = super.toJSON();
// Make sure that the password is not included in the response
delete json.password;
return json;
}
You can also use scopes for this
@Table
@DefaultScope(() => {
exclude: ['password']
})
export class User extends Model {...}
And then, for cases where you need it, you can create a different @Scope()
you can find more here https://github.com/sequelize/sequelize-typescript?tab=readme-ov-file#scopes
@Column({
get: () => undefined,
})
password: string;
Issue
How can I hide the password? is there any way to not select the password using typescript-sequelize?
Versions
Issue type
Actual behavior
Expected behavior
Steps to reproduce
Related code