When utilizing Sequelize on a join query, I am currently facing the issue where the data from the join table is presented as an array of objects instead of strings. The client specifically needs an array of strings.
Is it possible and advisable to achieve this with Sequelize? Or should I manually transform the data before sending it to the client?
Query
movie.findOne({
include: [
{
model: db.genre,
attributes: ['name'],
through: {
attributes: [],
},
},
})
Output
{
"id": 52,
"type": "movie",
"Genres": [
{
"name": "Action"
},
{
"name": "Comedy"
}
]
}
My ideal format for Genres would be:
"Genres": ["Action", "Comedy"]