My query looks something like
({
attributes: [[sequelize.fn('COUNT', sequelize.col('id')), 'commitCount']],
include: [
{
model: global.mysqlDb.Commit,
attributes: ['id'],
where: {
RepositoryId: req.params.repositoryId
}
}, {
model: global.mysqlDb.SourceFile
}
],
group: ['SourceFileId']
});
But the id
in the sequelize.col
is ambiguous because it could be from any of the tables. Any way for me to specify the table name as well?
The main way to do this is as follows: Team.hasMany(Player); Player.belongsTo(Team); Again, as mentioned, the main way to do it used a pair of Sequelize associations ( hasMany and belongsTo ).
sync(); The call to User. sync() above will cause Sequelize to synchronize the model with the database. The method will create the database table if it doesn't already exist.
You should be able to do sequelize.col('table.column')
and then it will automatically be quoted
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