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

309
Views
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
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!