Sometimes i only want to select a single value from multiple rows.
Lets imagine i have an account model which looks like this:
Account
- Id
- Name
- Age
And i would only like to select the names.
You would write something like this:
AccountModel.findAll({
where: {
Age: {
$gt : 18
}
},
attributes: ['Name'],
raw : true
});
But this would return in an array with objects.
[{Name : "Sample 1"}, {"Name" : "Sample 2"}]
I would like to get an array with only names like this:
["Sample 1", "Sample 2"]
Is it possible to achieve this with Sequelize? I've searched trough the documentation but couldn't find it.