在序列化中,您可以轻松添加order by子句。
exports.getStaticCompanies = function () { return Company.findAll({ where: { id: [46128, 2865, 49569, 1488, 45600, 61991, 1418, 61919, 53326, 61680] }, // Add order conditions here.... order: [ ['id', 'DESC'], ['name', 'ASC'], ], attributes: ['id', 'logo_version', 'logo_content_type', 'name', 'updated_at'] });};看看我如何添加
order对象数组?
order: [ ['COLUMN_NAME_EXAMPLE', 'ASC'], // Sorts by COLUMN_NAME_EXAMPLE in ascending order],
编辑:
一旦在
.then()诺言中收到对象,您可能必须订购这些对象。查看有关根据自定义顺序对对象数组进行排序的问题:



