SequelizeDatabaseError:ER_BAD_FIELD_ERROR:未知列'模型。[object Object]'在' where子句'

时间:2018-02-15 08:00:00

标签: sequelize.js

想要计算updatedAt列,然后将其与where子句

中的当前日期进行比较
const query = {
        where: {
            [sequalize.fn('ADDDATE', sequalize.col('updatedAt'), 5)]:
            {
                $lt: sequalize.fn('NOW'),
            },
        },
        force: true,
    };

错误:SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'models.[object Object]' in 'where clause'

1 个答案:

答案 0 :(得分:1)

首先将sequalize更改为sequelize :)

其次,您的where查询应如下所示:

where: sequelize.where(
        sequelize.fn('ADDDATE', sequelize.col('updatedAt'), 5),
        {
            $lt: sequelize.fn('NOW')
        }
    )