Sequelize: Does Sequelize.js support raw in attributes/columns?

Created on 11 May 2016  路  1Comment  路  Source: sequelize/sequelize

Does Sequelize.js support raw in attributes/columns?
Any clue about this?

models.OrgTraffic.findAll({
"attributes": ["org_name", "account_id", "account_name", {"raw": "sum(requests)"}], ...})
It seem to work for order by and group by.

http://stackoverflow.com/questions/37173678/raw-in-attributes

Thanks!

Most helpful comment

Actually, I realized that you can use the literal function. In my case, this one works:

models.OrgTraffic.findAll({
"attributes": ["org_name", "account_id", "account_name", [sequelize.literal('sum(message_count)'), 'mc'], ...})

>All comments

Actually, I realized that you can use the literal function. In my case, this one works:

models.OrgTraffic.findAll({
"attributes": ["org_name", "account_id", "account_name", [sequelize.literal('sum(message_count)'), 'mc'], ...})

Was this page helpful?
0 / 5 - 0 ratings