:warning: Help needed: :warning: I tried reading ...
# orm-help
r
⚠️ Help needed: ⚠️ I tried reading the documentation as much as possible. I am though hitting some kind of wall, when trying to lookup multiple scenarios for what later will be FullTextSearch when that is supported in mongodb.
Copy code
let filter = {
      include: {
        category: true,
        instructor: true,
        lections: true,
      },
      where: {
        OR: [
          {
            title: {
              startsWith: search,
              mode: 'insensitive',
            },
          },
          {
            title: {
              contains: search,
              mode: 'insensitive',
            },
          },
          {
            description: {
              startsWith: search,
              mode: 'insensitive',
            },
          },
          {
            description: {
              contains: search,
              mode: 'insensitive',
            },
          },
        ]
      }
    };
I get the following Typescript error. (Using Prisma 3.3.0)
Copy code
Argument of type '{ include: { category: boolean; instructor: boolean; lections: boolean; }; where: { OR: ({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { ...; } | { ...; })[]; }; }' is not assignable to parameter of type '{ select?: CourseSelect | null | undefined; include?: CourseInclude | null | undefined; where?: CourseWhereInput | undefined; orderBy?: Enumerable<...> | undefined; cursor?: CourseWhereUniqueInput | undefined; take?: number | undefined; skip?: number | undefined; distinct?: Enumerable<...> | undefined; }'.
  The types of 'where.OR' are incompatible between these types.
    Type '({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; })[]' is not assignable to type 'Enumerable<CourseWhereInput> | undefined'.
      Type '({ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; })[]' is not assignable to type 'CourseWhereInput[]'.
        Type '{ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; } | { title: { contains: any; mode: string; startsWith?: undefined; }; description?: undefined; } | { description: { ...; }; title?: undefined; } | { ...; }' is not assignable to type 'CourseWhereInput'.
          Type '{ title: { startsWith: any; mode: string; contains?: undefined; }; description?: undefined; }' is not assignable to type 'CourseWhereInput'.
            Types of property 'title' are incompatible.
              Type '{ startsWith: any; mode: string; contains?: undefined; }' is not assignable to type 'string | StringFilter | undefined'.
                Type '{ startsWith: any; mode: string; contains?: undefined; }' is not assignable to type 'StringFilter'.
                  Types of property 'mode' are incompatible.
                    Type 'string' is not assignable to type 'QueryMode | undefined'.ts(2345)
r
@Rene Nielsen 👋 Could you check if
search
here is not undefined?
The above works fine for me on the latest version.
r
Hi @Ryan I attached a screenshot showing data type of string + how i use the filter.
Im running on 3.3.0 also
If i delete the mode: 'insensitive', it works, so must be something with that. Im on the Mongodb provider.
Reading further into the error, it looks like its because im using string value and not a model called QueryType.
Copy code
Types of property 'mode' are incompatible.  Type 'string' is not assignable to type 'QueryMode | undefined'.ts(2345)`
r
I just tried with insensitive mode on Mongo and TypeScript doesn't complain. Could you update Prisma to the latest version and check?
r
Hmm, i already did upgrade to 3.3.0. I will try and see if i can figure out what causes the errorl
👍 1
r
It would be great if you could send me a sample reproduction so that I can check locally.
r
So for others looking into this. Ryan found the error. I needed to define the type of the filter.
let filter: Prisma.CourseFindManyArgs = {}
💯 1