So I have a Restaurant
entity that has a relation to User
that represents it's owner, I'm currently trying to find a restaurant and including the owner information but I can't find out how omit certain fields in relations, in this case a password field.
const [findErr, restaurant] = await to(Restaurant.find({
relations: ['logo', 'owner'],
skip: page * limit,
take: limit
}));
The easiest you can do is to use select: false
option in column of your password:
@Column({ select: false })
password: string
Other options are involving using of QueryBuilder.
The easiest you can do is to use
select: false
option in column of your password:@Column({ select: false }) password: string
Other options are involving using of QueryBuilder.
how do you login with
ts
@Column({ select: false })
password: string
how do you compare hash ?
@mkamranhamid You can select the columns you need with the select property which overrides @Column({ select: false })
:
const user = await userRepository.findOne({ where: { email }, select: ['id', 'password'] });
Most helpful comment
@mkamranhamid You can select the columns you need with the select property which overrides
@Column({ select: false })
:const user = await userRepository.findOne({ where: { email }, select: ['id', 'password'] });