Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

327
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda