首页 > 解决方案 > Sequelize 递减 JSON 列

问题描述

大家好,我正在使用 sequlize ORM,我正在尝试减少 JSONB 列

型号定义:

const condition = (sequelize, DataTypes) => sequelize.define(
    'condition',
    {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true,
        },
        value: {
            type: DataTypes.ENUM,
            values: ['YES', 'NO'],
        },
        typeId: {
            type: DataTypes.INTEGER,
        },
        position: {
            type: DataTypes.JSONB,
            defaultValue: {
                row: 1,
                col: 1,
            },
        },
    },
    {
        paranoid: true,
        timestamps: true,
    },
);

我一直在使用以下查询:

Model.decrement(
        "position.row",
        {
            by: 2,
            where: {
                'position.row': { [Op.gt]: 2 },
                TypeId: 2,
            },
        },
    );

但我得到了错误

错误:列“position.row”不存在

有谁知道我该如何解决这个问题?

标签: node.jssequelize.jssequelize-cli

解决方案


推荐阅读