【发布时间】:2019-03-12 21:13:11
【问题描述】:
我正在尝试通过以下方式在 booking_date 之前获取所有用户及其主要供应商、预订和服务订单。
Users.findAll({
where: { id: userId }, attributes: AttributesUser,
include: [{
model: MasterVendor, attributes: AttributesMasterVendor, required: true,
include: [{
model: Bookings, where: { booking_state: jobStatus, booking_date: _date }, attributes: AttributesBooking,
include: [{ model: Services, attributes: attributesService, order: ['Bookings.booking_date'] }],
}],
}],
});
但不幸的是,order by 子句根本没有生成。但是当我尝试按名称获取数据顺序时,它工作得很好
Users.findAll({
where: { id: userId }, attributes: AttributesUser,
include: [{
model: MasterVendor, attributes: AttributesMasterVendor, required: true,
include: [{
model: Bookings, where: { booking_state: jobStatus, booking_date: _date }, attributes: AttributesBooking,
include: { model: Services, attributes: attributesService }
}]
}],
order: ['name'],
});
请建议我,我做错了什么。 谢谢。
【问题讨论】:
标签: mysql node.js sequelize.js