I'm using Sequelize on a join query. Currently, the data from the join table is presented as an array of objects. The client expects an array of strings.
Is this something that can / should be done with Sequelize? Should I transform the data manually 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"
}
]
}
Ideally, I would like Genres to be formatted as:
"Genres": ["Action", "Comedy"]