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

255
Views
How to get grouped results without Associations? (based on shared value)

When I have Associations relation I can do:

  const results = await categoryModel.findAll({
    include: [
      {
        model: moviesModel,
      },
    ]}

And I will get the results like:

{ category_id: 1, name: "action" movies: [list of movies in the category] }

Is there I can get the same type of result without the categoryModel to query on? To query directly the movies model and get the results like so? so they will be grouped based on the category ID that they have?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sequelize is not about complex aggregation queries, it's just for CRUD with associations like any other ORM library.
You can only reduce attributes you want to get from the category model indicating the attributes option like this:

const results = await categoryModel.findAll({
    attributes: ['category_id'],
    include: [
      {
        model: moviesModel,
      },
    ]}
about 4 years ago · Juan Pablo Isaza Report
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!