Sequelize:s.replace 在使用文字更新时不是函数

Sequelize: s.replace not a function when using literal update

我有这个片段:

return await SongQueue.update({
    queue: literal('queue - 1') }, {
    where: {
        guildId: guild.id,
        [Op.gte]: from,
        [Op.lte]: to,
    },
});

我得到了这个错误:

UnhandledPromiseRejectionWarning: TypeError: s.replace is not a function

这段代码有什么问题?

类型: queuefromto:整数 guild.id: 字符串

你不能通过那个访问sequelize literal。试试这个。

return await SongQueue.update(
    { 
        queue: sequelize.literal('queue - 1')
    }, 
    {
    where: {
        guildId: guild.id,
        [Op.gte]: from,
        [Op.lte]: to,
    },
});

我忘记为 Op 过滤器设置列:

guildId: guild.id,
queue: {
    [Op.gte]: from,
    [Op.lte]: to,
}