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

311
Vistas
Only return items from db if the include items exists (Prisma)

I am trying to only return items from our DB, if the children within an include exists.

I am using Prisma to query our postgres DB. Previously, using sequelize, you could add a required:true to the include, meaning only items that had this include would be returned. However, I can not seem to do this with Prisma, so its returning many more items that I don't need.

Here is the structure that i have:

 where: {
      ...parameters_.where,
    },
    include: {
      Products: {
        where: {
          active: true,
          ParentId: parameters_.ParentId,
        },
      }
    }

So I only want to return the top level, if Products actually exists. (This will return an array, and currently it returns if the Products array is empty as well as when its not).

As mentioned, with sequelize it was possible to do the following:

      include: [
        {
            model: ModelName,
            as: "modelName",
            required: true
       },
      ]    
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