humblecoder
07/09/2022, 4:15 AMPrisma
JSON filter with array values? I’m trying:
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?Austin
07/11/2022, 8:25 PMstring_contains
, string_starts_with
, and string_ends_with
.
You can read more here.humblecoder
07/11/2022, 8:53 PMqueryraw
and using native PGSQL filtering. Would be nice to get this “natively”, but works for now. Thanks.Austin
07/11/2022, 8:56 PM