How can I create a "Where" clause with an OR. I ge...
# orm-help
p
How can I create a "Where" clause with an OR. I get that if I list multiple values in the where, they are all "AND"ed together. How to I make OR (or combinations of AND and OR's. I tried this as a wild guess but obviously too wild a guess. (lines 3-7 or so)
Copy code
const localData = await context.prisma.Sessions.findMany({
  where: {
    CodeCampYear: {
      UrlPostToken: year
    } || {
      Id: codeCampYearId
    }
  },
  select: {
    Id: true,
    CodeCampYearId: true,
    Title: true,
    CodeCampYear: {
      select: {
        Id: true,
        UrlPostToken: true,
      },
    },
  },
});
p
Thanks. I totally don't get how the docs are organized. I was on that page, but up about 200 pages from the answer. All I found was this: select?: XOR<UserSelect, null> which did not help me though I'm guessing to others, it's obvious.
If anyone else looks, here is what I wanted that works.
Copy code
const localData = await context.prisma.Sessions.findMany({
  where: {
    OR: [
      {
        CodeCampYear: {
          Id: codeCampYearId,
        },
      },
      {
        CodeCampYear: {
          UrlPostToken: year,
        },
      },
    ],
  },
  select: {
    Id: true,
    CodeCampYearId: true,
    Title: true,
    CodeCampYear: {
      select: {
        Id: true,
        UrlPostToken: true,
      },
    },
  },
});