TypeORM - never return the password from the database when fetching a user

前端 未结 1 1601
南笙
南笙 2021-01-19 08:33

I created a REST API using NestJs with TypeORM. Basically this is my user entity

@Entity(\'User\')
export class User extends BaseEntity {
  @PrimaryGenerated         


        
相关标签:
1条回答
  • 2021-01-19 09:20

    Just add the select: false option to the column definition. With it, the column won't be selected unless explicitly added via addSelect, see the docs.

    @Entity()
    export class User {
    
        @Column({select: false})
        password: string;
    }
    
    0 讨论(0)
提交回复
热议问题