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

256
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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