Sunday 21 May 2017

How to query virtual column using Sequelize?

There is a Sage in Student table, I want to query the year of birth of a student using 2017-Sage, but I don't know how to do it, I have tried to do like this:

db.Student.findAll({
        attributes: ['Sname','Ssex',[2017-Sequelize.col('Sage'),'Year of birth']],
        where: {
            Clno: {
                $in: ['01311','10665']
            }
        }
    })

but it comes the error:

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: attr[0].indexOf is not a function



via laoqiren

No comments:

Post a Comment