I am issue while forming a sequelize query :
My Native query is something.
SELECT max(id),vehicleID FROM `vehicles` WHERE `vehicles`.`vsr_id`=342;
For this i am trying to build Code which something like this.
Vehicle.find({ where: { 'vsr_id': 342 }, order : [sequelize.fn('max', sequelize.col('id'))] }).success(function(vehicles){
console.log("Something i got" + vehicles)
})
It throwing an error : sequelize Object [object Object] has no method 'col' and i refered from this URL: http://sequelizejs.com/docs/latest/models#block-34-line-8
Any code missings from my end. Please help me out
FYI: Ignore semicolons
Can you please try,
Vehicle.max('id', {where : {'vsr_id': 342 }})
.success(function(vehicle_id){
...
})
.error(function(error){
...
});
That query should be possible with:
Vehicle.findAll({
attributes: [
sequelize.fn('MAX', sequelize.col('id'))
],
where: {
{ 'vsr_id': 342 }
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With