Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

447
Vistas
How to Create data and return it with an association in Sequelize

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
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda