When using Sequelize, I want to specify the order clause only for the main query, but the order clause is also applied to subqueries. How can I apply the order clause to the main query only?
■ Sequelize version
3.30.4
■ RDB
MySQL 5.7
Parents.hasMany(models.Children, {
foreignKey: 'parent_id'
});
Children.belongsTo(models.Parents, {
foreignKey: 'parent_id'
});
Parents.findOne({
order: "id asc",
include: [Children]
})
SELECT
`Parents`.*,
`Children`.`id` AS `Children.id`,
`Children`.`parent_id` AS `Children.parent_id`,
FROM
(
SELECT
`Parents`.`id`,
FROM
`Parents` AS `Parents`
ORDER BY
id asc
LIMIT
1
) AS `Parents`
LEFT OUTER JOIN `Children` AS `Children` ON `Parents`.`id` = `Children`.`parent_id`
ORDER BY
id asc;
subquery
ORDER BY id asc
I would like to delete the order