我正在编写一个 prisma 查询,但我需要知道一个字符串是否存在于另一个字符串中。
在 prisma 中我们可以做到这一点
where: {
id: { in: [22, 91, 14, 2, 5] },
},
Run Code Online (Sandbox Code Playgroud)
对于数组。但我希望能够检查字符串中是否存在属性值。像这样的事情
where: {
comment: { in: "some random string containing the value in comment" },
},
Run Code Online (Sandbox Code Playgroud)
那么comment: 'the value'它是否应该与上面的查询匹配。我在 prisma 文档中找不到此类操作的示例。
我正在寻找 string_contains 函数的反函数。基本上相当于这个SELECT * FROM table WHERE POSITION(comment IN "some random string containing the value in comment") > -1
小智 8
我认为你想要做的事情可以通过使用 prisma 过滤和排序功能来完成contains。
在你的情况下,它应该看起来像:
where: {
comment: { contains: "the value" },
},
Run Code Online (Sandbox Code Playgroud)
the value上面的查询将返回包含on列的记录comment。
你可以看看这个文档Prisma 过滤和排序并查看过滤器关于关系的部分
| 归档时间: |
|
| 查看次数: |
11527 次 |
| 最近记录: |