Reputation: 133
I am completely new to both nodejs and SQL / Sequelize. But I fight my way through!
I have a query here, which I would like to implement with Sequelize.
If I am already informed, I can do this with sequelize.literal
.
Maybe you can help me.
SELECT ytd.*
FROM youtubedata ytd
WHERE ytd.date = (SELECT MAX(ytd2.date) FROM youtubedata ytd2);
Upvotes: 0
Views: 269
Reputation: 22758
Something like this:
const items = await database.youtubedata.findAll({
where: Sequelize.where(Sequelize.col('date'), '=', Sequelize.literal('(SELECT MAX(ytd2.date) FROM youtubedata ytd2)'))
})
Upvotes: 1