I am writing a prisma query but I need to know if a string exist in another string.
In prisma we can do this
where: {
id: { in: [22, 91, 14, 2, 5] },
},
for arrays. but I want to be able to check if the property value exist in a string. Some thing like this
where: {
comment: { in: "some random string containing the value in comment" },
},
So if comment: 'the value' it should match the query above. I can not find a sample of this kind of operation in the prisma doc.
I am looking for inverse of the string_contains function. basically the equivalent of this SELECT * FROM table WHERE POSITION(comment IN "some random string containing the value in comment") > -1
I think what you are trying to do can be done by using prisma filtering and sorting function contains.
In your case, it should be looks like:
where: {
comment: { contains: "the value" },
},
The above query will return you the records that contains the value on comment column.
You can have a look on this document Prisma Filtering and sorting and check out the part of Filter on relations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With