Can `Prisma` JSON filter with array values? I’m t...
# orm-help
h
Can
Prisma
JSON filter with array values? I’m trying:
Copy code
findMany({
        where: {
          my_json_field: {
            path: ['my','path'],
            in: ['park','car','house'],
          },
        },
. . . but I’m receiving a TS error
Type '{ path: string[]; in: any[]; }' is not assignable to type 'JsonNullableFilter'.
However, changing types doesn’t seem to matter. The path contains a single text value. It is not an array. But I still want to see if the value is “IN” the provided array. I can do this with a raw query, but I’d rather have Prisma handle it in this case for further operations. Is array filtering even possible with JSON values?
1
a
Hey there! If you are operating on a single string field, you can’t do this type of filtering. The operations available are
string_contains
,
string_starts_with
, and
string_ends_with
. You can read more here.
h
Thanks. I ended up accomplishing it with a
queryraw
and using native PGSQL filtering. Would be nice to get this “natively”, but works for now. Thanks.
a
Feel free to open a feature request!