mariadb,
show tables;
Board
Comment
my code,
models.Board.findAll({
attributes: [
'_no', 'title', 'content', 'createdAt'
],
include: [
{
model: models.Comment,
tableAlias: 'Comment',
attributes: [
[models.sequelize.fn('count', models.sequelize.col('_no')), 'comment']
]
}
],
group: ['_no', 'title', 'content', 'createdAt'],
order: [
['createdAt', 'DESC']
],
raw: true
}).then(function(boards)
{
res.send(JSON.stringify(boards));
});
Why error occurs?
Unhandled rejection SequelizeDatabaseError: ER_NON_UNIQ_ERROR: Column '_no' in field list is ambiguous
models.sequelize.col('_no') -> models.sequelize.col('models.Comment._no') error, too.
models.sequelize.col ( '_ no') in the _no want to use Comment table.
thanks.