Skip to content
Advertisement

How can I convert SQL-query to Sequelize?

I have this SQL query:

It returns the last message in the given chat.

But I don’t understand at all how to execute this moment IN (SELECT MAX(messages.id) FROM messages GROUP BY messages.chatId)) AS lastMessage ON chats.id = lastMessage.chatId in Sequelize…

Advertisement

Answer

You can use Sequelize.literal like this:

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