I have below method in nestjs.
async findOne(userId: string) {
const user = await this.userRepository.find({userId});
if (user) {
throw new NotFoundException(`User does not exist`);
}
return user;
}
this method retunrn an array of object. if value not found in DB it return [{}].
I need to throw exception when it return empty array I mean [{}]. for that I need to put condition in if block
when I write user, or user==null or user.length==o in if block , in all the case it is not going inside the if
what modification I need to do in if block?