IT
Prisma include 작성자 사용자 정보 함께 조회
agnusdei1207
2023. 8. 25. 14:54
반응형
SMALL
0. 마우스를 가져다 대면 유저 테이블을 조회한다는 사실을 알 수 있습니다.
const entities = await this.prismaService.influencerRequest.findMany({
where,
orderBy,
take: option.pageSize,
skip: (option.pageNo - 1) * option.pageSize,
include: {
// 사용자 정보를 포함하여 조회
user: {
select: { nickname: true, username: true },
},
},
});
1. include 를 활용하여 user 테이블을 조회합니다.
2. 사용할 컬럼만 지목해서 가져옵니다. (닉네임, 성명)
3. true 를 명시하면 해당 컬럼 데이터도 가져오겠다는 뜻입니다.
반응형
LIST