What I Learned/SpartaCodingClub
[내일배움캠프] 2022-12-21 TIL
Interrobang
2022. 12. 21. 16:41
Sequelize사용 시 create, findAll, findOne, update, destroy 활용
await Comment.create({ postId: _postId, userId, comment });
await Comment.findAll({
attributes: ['commentId', 'userId', 'comment', 'createdAt', 'updatedAt'],
include: [
{
model: User,
attributes: ['nickname']
}
],
where: { postId: _postId },
order: [
['createdAt', 'DESC']
],
});
await Comment.findOne({ where: { commentId: _commentId }})
await Comment.update({ comment }, { where: { commentId: _commentId }});
await Comment.destroy({ where: { commentId: _commentId }});