I have the following code
Locations.findAll({
attributes: ['id', 'location_name'],
include: [{
model: Somemodel,
attributes: ['hierarchy_name']
}]
})
This will provide an output like this:
id: 1
location_name: "City"
parent_id: 0
hierarchy: 1
location_hierarchy: {hierarchy_name: "Division"}
Is there any way that i can get the hierarchy_name without nesting the output with sequelize? Like this:
id: 1
location_name: "City"
parent_id: 0
hierarchy: 1
hierarchy_name: "Division"
I know that i can destructure the data before sending it to client and i will get the format i want. But i want to know if this can be done directly from sequelize.