简体   繁体   English

我如何将查询翻译为续集?

[英]How can i translate query to sequelize?

select reservation_datetime
from LectureReservation
Inner Join Lecture
On LectureReservation.lecture_id = Lecture.id
Where Lecture.mentor_id = 1

This is my query and I want to change it to sequelize like这是我的查询,我想将其更改为续集

if (req.params.id) {
            LectureReservation
            .findAll({
                include: [{
                    model: Lecture,
                    where: { mentor_id: req.params.id },
                }],
                attributes: ['reservation_datetime'],
                where: {
                    lecture_id: Lecture.id,
                },

this.. I tried it so hard but can't find solution and my postman keep showing me这个..我很努力,但找不到解决方案,我的 postman 不断向我展示

"name": "SequelizeEagerLoadingError"

this err..这个错误。。

plz help me to translate query to sequelize..!请帮我将查询翻译为续集..!

Sequelize will do _outer join without required = true. Sequelize 将执行 _outer join 而无需 required = true。

The errors you have received usually is from association problem.您收到的错误通常来自关联问题。

Try set logging:console.log and check the raw query.尝试设置 logging:console.log 并检查原始查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM