Reputation: 778
I have a problem whith join using sequelize.js. I need a last History date for all users. I'm try this, but something is wrong:
this.users.findAll({
include: [
{
model: History,
attributes: [
'value',
'date'
],
having: { date: [sequelize.fn('MAX', sequelize.col('date')), 'max_date']}
}
]
}
This does not work, I wonder if you have any idea how to return this result.
Thanks
Upvotes: 1
Views: 540
Reputation: 58543
I think you can do this by order by
and limit
, Here you go :
this.users.findAll({
include: [
{
model: History,
separate : true ,
order : [['date','desc']] ,
limit : 1
}
]
}
Upvotes: 1