Last active
September 4, 2019 22:30
-
-
Save BolajiOlajide/ea757da4b809d0c2dacbe1e9c408017e to your computer and use it in GitHub Desktop.
Using sequelize cast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Sequelize from 'sequelize'; | |
const { | |
Op, | |
col: sequelizeCol, | |
cast: sequelizeCast | |
} = Sequelize; | |
// http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#static-method-cast | |
const valueCast = sequelizeCast(sequelizeCol('value'), 'int'); | |
const settingsQuery = { | |
where: { name: { [Op.like]: '%QuotaMax' } }, | |
attributes: ['name', [valueCast, 'value']], | |
order: [[valueCast, 'ASC']] | |
}; | |
const scoreBands = await models.Setting.findAll(settingsQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment