sequelize: order with camelcase column name gives an error

with sequelize version 2.0.0-rc2, my simple sorting, where the db column in postgres is updatedAt, is as follows:

db.MachineRequest.findAll({
      where: { approved: true },
      order: 'updatedAt'
})

It gives me this error - seems like it is always lowercasing it:

Cannot display approved machine requests: SequelizeDatabaseError: error: column "updatedat" does not exist

I have tried putting backtick symbol around updatedAt and it gives the same error:

Any idea how to order by a column name that has camel case? Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 1
  • Comments: 22 (9 by maintainers)

Most upvoted comments

You have to write it like this:

findAll({ order: '"createdAt" DESC' })

Using a string directly for order is not recommended and will likely go away in the future. Use [['updatedAt', 'DESC']].