Accesses.findAll({
include: [{
model: StationTypes,
as: 'StationTypes',
}],
order: [['StationTypes', 'Order', 'ASC']],
where: { ... },
}).then(...)
Users.findAll({
...
order: [
[Roles, 'created_at', 'asc']
],
include: [
{
model: Roles,
},
],
...
});
const categories = await models.Category.findAll({
attributes: ['id', 'title', 'description'],
order: [['title', 'ASC'], [models.Product, models.Price, 'createdAt', 'DESC']],
include: [
{
model: models.Product,
attributes: ['id', 'title'],
through: { attributes: [] },
include: [
{
model: models.Price,
attributes: ['id', 'amount', 'createdAt'],
separate: true,
limit: 1,
},
],
},
],
});