First, sorry about the bad english, non native speaker. In Sequelize i have created a CRUD without any problems great ORM tool, still i would like to create and return a specific data with an association.
async create(req, res){
const {minRoll,maxRoll,typeName} = req.body;
const actionType = await ActionType.findOne({
where: {name: typeName}
});
if(!actionType){
return res.json({result:false});
}
const {id} = actionType;
const action = await Action.create({
minRoll: minRoll,
maxRoll: maxRoll,
type_id: id
});
return res.json(action);
},
How to create and return action with an association? This is my return in Postman at the moment:
"id": 61,
"minRoll": 1,
"maxRoll": 3,
"type_id": 20