Issue about timestampdiff function in sequelize

42 views
Skip to first unread message

Gabriel Mata

unread,
Oct 26, 2022, 2:37:20 PM10/26/22
to Sequelize
Hello Mates!

I´m new in this group, nice to meet you , please i need your help about a proble thar have with sequealize sentence, i need  select registry that have,
timestampdiff between a column (date) and the actual hour, my problen is that it always returns the record even if it doesn't meet the conditio,

this a query generate sequelize i run in workbrench mysql works but en nodejs no works

SELECT *FROM `pau` AS `pau` WHERE timestampdiff(minute, `last_date_test`, now()) >= 8 AND `pau`.`ping_test` = 1 LIMIT 1;

this my code:

 pauSelect = await pauModel.findOne({
        limit: 1,
        where: {
            ping_test: 1,
            [Op.eq]: sequelize.where(
                sequelize.fn(
                    'timestampdiff',
                    sequelize.literal('minute'),
                    sequelize.col('last_date_test'),
                    sequelize.fn('now')
                   ,

                ), ">=", minutes)
            /*{
                [Op.gte]: minutes
            }*/
           
        },
    })


Reply all
Reply to author
Forward
0 new messages