I create a user entity with password-
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({ type: "text", nullable: false })
userName: string;
@Column({ type: "text", nullable: false })
email: string;
@Column({ type: "text", nullable: false })
firstName: string;
@Column({ type: "text", nullable: false })
lastName: string;
@Column({ type: "text", nullable: false, select: false }) //It is select as false
password: string;
@Column({ type: "text", nullable: true })
socket_id: string;
@Column({ type: "text", nullable: true })
avatar: string;
@Column({ type: "boolean", default: false, nullable: false })
is_verify: boolean;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn()
updated_at: Date;
}
In this entity
, I set select
as false
. When I find it, now password
I am not seeing password
column. It's okay for me.
But some time I need this password column to verify password. Then I how can I find this column. I am not getting any idea. Please help any-
const user = await this.userRepository.findOneBy({
email: loginInput.email,
is_verify: true
})
console.log(user)
What things I have to change in this code to get password column also.
You can select hidden column :
const user = await this.userRepository.findOne({
where: {
email: loginInput.email,
is_verify: true,
},
select:{
password:true,
},
});
console.log(user);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.