In mysql query if I want to retrieve static value as column in select query I would normally use following statement:
SELECT
...,
"static value" as static_value
FROM table_name;
How can I accomplish such queries in sequelize findAll?
In mysql query if I want to retrieve static value as column in select query I would normally use following statement:
SELECT
...,
"static value" as static_value
FROM table_name;
How can I accomplish such queries in sequelize findAll?
You can use sequelize.literal()
Model.findAll({
attributes: ['foo', 'bar', [sequelize.literal('static value'), 'static_value']]
});
Which is the equivalent of
SELECT foo, bar, 'static value' AS static_value FROM ...