MySQL DB 설계부터 Sequelize 구현까지 알아보기!
sequelize api 구현
다른 테이블 데이터 참조 방법
Exclude primary key attributes from a sequelize query
모델 생성 및 옵션 설정
config.json파일 내용 환경변수 처리
정렬
commentRouter.get("/:postId", async (req, res) => {
try {
const { postId } = req.params;
const comments = await Comment.findAll({
where: { postId },
include: [
{
model: User,
attributes: ["nickname"],
},
],
order: [["createdAt", "DESC"]], // DESC 내림차순, ASC 오름차순
});
N:N belognsToMany