Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

445
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!