JsonFilter中不存在路径



不确定发生了什么。使用带有mongoDB连接的Prisma。尝试在JSON树中搜索与循环中的[key,value]匹配的特定值。我还没能深入了解这个实现是否可行(我认为它不会(,因为path属性一直在出错。下面是我的schema.prisma文件和回调返回的错误消息。

generator client {
provider        = "prisma-client-js"
previewFeatures = [ "mongoDb", "filterJson"]
}
datasource db {
provider = "mongodb"
url      = env("DATABASE_URL")
}
model User {
id       String @id @default(dbgenerated()) @map("_id") @db.ObjectId
email    String
options  Json
password String
role     String
}
Invalid `.findMany()` invocation 
for (const [key, value] of Object.entries(filters)) {
return await prisma.user
→     .findMany({
where: {
options: {
path: key,
~~~~
equals: value
}
}
})
Unknown arg `path` in where.options.path for type JsonFilter. Did you mean `not`? Available args:
type JsonFilter {
equals?: Json
not?: Json
}

已经多次运行npx棱镜生成。包括";滤波器Json";功能如文档所示。我已经在谷歌上搜索了所有我能搜索到的东西,但我似乎找不到哪里出了问题。

有什么帮助吗?

我认为mongo DB不支持json字段上的过滤器和/或prisma不支持底层功能。

(https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filter-现场(

医生说

Json过滤的实现在连接器之间有所不同:

  • MySQL连接器使用MySQL对JSON路径的实现
  • PostgreSQL连接器使用自定义JSON函数和运算符在版本12及更早版本中支持

函数性似乎只支持postgre>=12和mysql

编辑:找到以下内容:https://github.com/prisma/prisma/discussions/10592

表示

嘿@LewisMorgans,这还没有。