Sequelize decrement JSON column

274 Views Asked by At

Hi guys I'm using sequlize ORM and I'm trying to decrement the JSONB column

Model definition:

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,
    },
);

I have been using following query:

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

But I'm getting the error

error: column "position.row" does not exist

Does anyone know how could I resolve this issue?

0

There are 0 best solutions below