sequelize node js count in include code example
Example 1: sequelize count in include
Location.findAll({
attributes: {
include: [[Sequelize.fn("COUNT", Sequelize.col("sensors.id")), "sensorCount"]]
},
include: [{
model: Sensor, attributes: []
}]
});
Example 2: count using sequelize.fn
exports.getMinPrice = () => Item.findAll({ attributes: [[sequelize.fn('min', sequelize.col('price')), 'minPrice']], });