import { UserEntity } from '@adachi-sakura/nest-shop-entity' ; import { EntityRepository , Repository } from 'typeorm' ; @ EntityRepository ( UserEntity ) export class UserRepository extends Repository < UserEntity > { async findOneByPhoneOrEmail ( phone , email ) ; async findOneByPhoneOrEmail ( phoneOrEmail ) ; async findOneByPhoneOrEmail ( phoneOrEmail , email ? ) { return await this . createQueryBuilder ( 'user' ) . leftJoinAndSelect ( 'user.phoneNumbers' , 'user_phoneNumbers' ) . leftJoinAndSelect ( 'user.email' , 'user_email' ) . where ( 'user_phoneNumbers.phoneNumber = :phoneOrEmail' , { phoneOrEmail } ) . orWhere ( 'user_email.email = :email' , { email : email || phoneOrEmail } ) . getOne ( ) ; } }