How to do where in
, for JSON columns in Prisma 5.x.x
#24211
Replies: 2 comments
-
Hi @AndrewKralovec 👋 Thank you for raising this question. In Prisma 5.x.x, there have been changes to the way Also, it seems like you're trying to use the You will need to update your code to use the filters mentioned in the documentation. |
Beta Was this translation helpful? Give feedback.
-
@ludralph , thank you. Yes, I managed to get it work by spreading the emails into the OR statement. const result = await prisma.user.findMany({
where: {
OR: [
...(input.emails.map(e => ({
user_data: {
path: ['user', 'email'],
equals: e
}
}))
],
},
}) My apologies for not finding that open issue about supporting the IN operator. I must have missed it in my search. |
Beta Was this translation helpful? Give feedback.
-
Question
I’m trying to migrate from prisma 3.x.x, to version 5.x.x. However, I’m having a problem trying to do a
where In
, on a JSON column.This used to work, but when trying in the new version produces an error. Does anyone know how to achieve this on the new version (example posted below) ? It’s not listed in the docs. Any insight would be appreciated.
https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-a-json-field-simple
How to reproduce (optional)
Have a JSON column. Try to search on a property using a
where in
.Expected behavior (optional)
It translates the
where in
query.Information about Prisma Schema, Client Queries and Environment (optional)
OS: macOS
Database: PostgreSQL
Node.js version: v20
Run
prisma -v
to see your Prisma version and paste it^5.13.0
Beta Was this translation helpful? Give feedback.
All reactions