2

I have a sequelize in a MySQL model with column as follows:

      date: {
                    type: Sequelize.DATE,
                    field: 'utxn_date',
                    defaultValue: () => {
                        const now = new Date();
                        return `${formatISO(now, { representation: 'date' })} ${formatISO(now, {
                            representation: 'time',
                        })}`;
                    },
                },

At some moment, I need to filter this column, that I use the following code in my where (I tried to put a Date() component and also tried with a string as follows:

where = {
    ...where,
    [sequelize.Op.lte]: {
        date: '2020-05-06 23:59', //endDateFilter,
    },
};

But, at every time, I got this error:

"Invalid value { utxn_date: '2020-05-06 23:59' }"

If I do a SELECT directly on my database, the result of the column will be as follow:

utxn_id | utxn_user_id |      utxn_date      | utxn_value
--------+--------------+---------------------+------------
 26     | 200          | 2019-10-26 10:15:52 | 100.00

Details about the table:

column      |  type
------------+------------
utxn_id     | bigint(20)
utxn_user_id| int(11)
utxn_date   | datetime

Everything seems to be fine. In other moments I used similar filters in Sequelize.DATE columns and worked well. What I'm doing wrong?

William Prigol Lopes
  • 1,803
  • 14
  • 31

0 Answers0