강의

멘토링

커뮤니티

Inflearn Community Q&A

cloer's profile image
cloer

asked

[Renewed] Node.js Textbook - From Basics to Project Practice

Implementing following and followers

시퀄라이저 -> sql 질문

Written on

·

238

0

시퀄라이즈 문법이 아직 익숙하지 않아 질문드립니다. 

deserializeUser 안의 내용인

User.findOne({
where: { id },
include: [
{
model: User,
attributes: ['id', 'nick'],
as: 'Followers',
},
{
model: User,
attributes: ['id', 'nick'],
as: 'Followings',
},
],
})

이 부분을

select *
FROM (
SELECT *
FROM users
WHERE id = {세션에서 가져온 id}
) as user
LEFT JOIN (
SELECT followingId, followerId
FROM Follow
) as Follow on user.id = Follow.followingId
LEFT JOIN (
SELECT id, nick
FROM users
) as Follower on Follow.followerId = Follower.id;

시퀄라이저에서 Followers 까지만 적성해봤습니다. 이런식으로 이해하면 될까요? 

 

mysqlnodejsmongodbSequelize

Answer 1

0

cloer님의 프로필 이미지
cloer
Questioner

요청 보내면 시퀄라이저가 콘솔에 띄워주는 쿼리 보고 해결됬습니다.

cloer's profile image
cloer

asked

Ask a question