I asked on GH but was hoping someone might know th...
# orm-help
b
I asked on GH but was hoping someone might know the answer, I am trying to write a query that returns a list of resources that are available for a given range. The issue however is that I cannot seem to find any documentation on referencing custom values in the
where
statement. For now I am using a raw query but would rather not if possible. Current:
Copy code
SELECT "Resource".*
    FROM "Resource"
    LEFT JOIN "Appointment" ON "Appointment"."resourceId" = "Resource"."id"
    WHERE "Appointment"."id" IS NULL
    OR NOT (
        "Appointment"."startAt" < ${range.endDate}
        AND ("Appointment"."startAt" + INTERVAL '1 Minute' * "Appointment"."duration") > ${range.startDate}
    );
Desired:
Copy code
prisma.resource.findMany({
    where: {
      appointments: {
        none: {
          startAt: { lt: range.endDate },
          // How do I query:
          // ("Appointment"."startAt" + INTERVAL '1 Minute' * "Appointment"."duration") > ${range.startDate}
        },
      },
    },
  });
n
Hey Bailey 👋 Welcome to our community! We have a feature request for this same use case: #5560 If you could leave a 👍 to the request it would help our product team in prioritising it.