Skip to content
Advertisement

Converting a SQL query to SEQUELIZE

I am trying to wrap my head around creating this sequelize query.

I have been able to create 2 separate queries where the ‘order by filter’ works and ‘aliases’ work, but not combined.

This is what i currenty have in sequelize

Advertisement

Answer

You just need to use fn twice: in order and in attributes options:

Also you can combine findAll and count queries into one findAndCountAll and you will get the result with two props: rows and count:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement