Reputation: 1518
I'm trying to get id
of AttributeValue model with an alias of attribute_value_id
as below but attribute_value_id
seems undefined
in otherOptions
constant.
const otherOptions = await AttributeValue.findAll({
where: {
id: {
[Op.in]: attributeValueIds
} },
attributes: [
['id', 'attribute_value_id'],
'attribute_id',
'value'
]
})
I'm fallowing sequlize documantation about querying and the below query is built by sequelize but there is no alias attribute in the resulting object.
SELECT `id` AS `attribute_value_id`, `attribute_id`, `value` FROM `attribute_values` AS `attribute_value` WHERE `attribute_value`.`id` IN (1, 1, 1, 1, 19);
Upvotes: 1
Views: 488
Reputation: 41
You can get it with otherOptions[0].getDataValue('attribute_value_id')
Upvotes: 2