Fun with Sequelize ordering


I may have been lying about the ‘fun’ part :smile:

Ultimately my problem has come down to this:

const applications = await Application.findAll({
    order: ['createdAt', 'ASC'],
    distinct: true,
    attributes: [ 

Adding the ‘ASC’ ordering property results in a query that seems to look for ‘ASC’ as an actual column: DatabaseError [SequelizeDatabaseError]: Unknown column 'application.ASC' in 'order clause'.

Removing ‘ASC’/‘DESC’ orders the results correctly, but I need to be able to change between ascending and descending results, and I think I’m using the correct syntax: shown here

Has anyone got any ideas?




But for anyone interested, the syntax is order: [ [ 'createdAt', 'ASC' ] ]

  • a nested array :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.