[Web-BackEnd]

Sequelize include한 데이터 정렬하는 방법

sizzF 2020. 7. 14. 18:11
const fullUser = await db.User.findOne({
                where: { id },
                attributes: ['id', 'nickname'],
                include: [{
                    model: db.TodoList,
                    attributes: ['id', 'startDate', 'finish'],
                }],
                order: [[{ model: db.TodoList },'startDate', 'ASC']],
            });

include먼저 해주고 나서 order써서 정렬하는 모델을 정해준다