Thursday 28 June 2018

Enum ordering in Sequelize/Postgres

Hello! I've been using Sequelize to work with a Postgres DB for the last few weeks and it has been working fine so far. The current problem I'm facing is that apparently Sequelize doesn't allow ordering your result by an ENUM field.I have a table in my DB with an ENUM field defined with this array: [campaign.APPROVED, campaign.WAITING_APPROVAL, campaign.REJECTED];And I'd like to get a list of all my campaigns and I want the order to be approved, rejected, waiting for approval. Unfortunately Sequelize is not capable of this and I haven't found a direct way of doing with raw queries. Am I missing something with Sequelize or going with raw queries is my only option? If so could someone help me out with how I can achieve it?

Submitted June 28, 2018 at 03:46PM by SeraphineX93

No comments:

Post a Comment