TIL 2020/10/08

코드깎는 노인·2020년 10월 8일
0
const profile = await getConnection()
      .createQueryBuilder()
      .select('profile')
      .from(Profile, 'profile')
      .where('profile.user = :userId', { userId })
      .execute();
 //리턴값  
 [
   {
     profile_id: '68d4b3d7-7ec6-4117-a2f2-b775898aeb2a',
     profile_gender: 'MALE',
     profile_birthday: null,
     profile_address: 'Seoul',
     profile_addressDetail: 'guro',
     profile_deletedAt: null,
     profile_createdAt: 2020-10-08T04:52:51.000Z,
     profile_updatedAt: 2020-10-08T04:52:51.000Z,
     profile_userId: 'efcd65b7-f91d-498e-b6b0-9cb34528961b'
   }
 ]
 //리턴값 

const profile = await getConnection()
      .createQueryBuilder()
      .select('profile')
      .from(Profile, 'profile')
      .where('profile.user = :userId', { userId })
      .getOne();
 //리턴값     
      {
     id: '68d4b3d7-7ec6-4117-a2f2-b775898aeb2a',
     gender: 'MALE',
     birthday: null,
     address: 'Seoul',
     addressDetail: 'guro',
     deletedAt: null,
     createdAt: 2020-10-08T04:52:51.000Z,
     updatedAt: 2020-10-08T04:52:51.000Z
   }
  //리턴값       

쿼리빌더에서 리턴값은 excute가 아닌 getone으로받아야 원래 테이블키값으로 나온다

profile
내가 볼려고 만든 블로그

0개의 댓글