[英]How to get unselected column in typeorm?
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
.在此
entity
中,我将select
设置为false
。 When I find it, now password
I am not seeing password
column.当我找到它时,现在
password
我没有看到password
列。 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 :你可以select 隐藏栏目:
const user = await this.userRepository.findOne({
where: {
email: loginInput.email,
is_verify: true,
},
select:{
password:true,
},
});
console.log(user);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.