admin管理员组文章数量:1022777
So here's my prisma schema:
model User {
id String @id @default(uuid())
email String @unique
mailing_address String
password String
verification_token String?
verification_token_expires DateTime?
reset_password_token String?
reset_password_expires DateTime?
name String?
roles Role[]
last_auth_change DateTime @default(now())
}
enum Role {
SUPER_ADMIN
ADMIN
USER
EMAIL_VERIFIED
UNVERIFIED
}
and i want to notify all the super admins when a user verify his email
the sql query for it is :
'SELECT "id", "mailing_address", "roles" FROM "User" WHERE "roles" @> ARRAY[\'SUPER_ADMIN\']::"Role"[] ;'
but i couldn't figure out how to do it with PRISMA , because when i want to write something in the where clause for roles in Prisma, the only option is equal
So here's my prisma schema:
model User {
id String @id @default(uuid())
email String @unique
mailing_address String
password String
verification_token String?
verification_token_expires DateTime?
reset_password_token String?
reset_password_expires DateTime?
name String?
roles Role[]
last_auth_change DateTime @default(now())
}
enum Role {
SUPER_ADMIN
ADMIN
USER
EMAIL_VERIFIED
UNVERIFIED
}
and i want to notify all the super admins when a user verify his email
the sql query for it is :
'SELECT "id", "mailing_address", "roles" FROM "User" WHERE "roles" @> ARRAY[\'SUPER_ADMIN\']::"Role"[] ;'
but i couldn't figure out how to do it with PRISMA , because when i want to write something in the where clause for roles in Prisma, the only option is equal
1 Answer
Reset to default 3Currently there's an open request here so equals
is the only available argument.
As a workaround, you can use a raw query as above via prisma.$queryRaw
.
So here's my prisma schema:
model User {
id String @id @default(uuid())
email String @unique
mailing_address String
password String
verification_token String?
verification_token_expires DateTime?
reset_password_token String?
reset_password_expires DateTime?
name String?
roles Role[]
last_auth_change DateTime @default(now())
}
enum Role {
SUPER_ADMIN
ADMIN
USER
EMAIL_VERIFIED
UNVERIFIED
}
and i want to notify all the super admins when a user verify his email
the sql query for it is :
'SELECT "id", "mailing_address", "roles" FROM "User" WHERE "roles" @> ARRAY[\'SUPER_ADMIN\']::"Role"[] ;'
but i couldn't figure out how to do it with PRISMA , because when i want to write something in the where clause for roles in Prisma, the only option is equal
So here's my prisma schema:
model User {
id String @id @default(uuid())
email String @unique
mailing_address String
password String
verification_token String?
verification_token_expires DateTime?
reset_password_token String?
reset_password_expires DateTime?
name String?
roles Role[]
last_auth_change DateTime @default(now())
}
enum Role {
SUPER_ADMIN
ADMIN
USER
EMAIL_VERIFIED
UNVERIFIED
}
and i want to notify all the super admins when a user verify his email
the sql query for it is :
'SELECT "id", "mailing_address", "roles" FROM "User" WHERE "roles" @> ARRAY[\'SUPER_ADMIN\']::"Role"[] ;'
but i couldn't figure out how to do it with PRISMA , because when i want to write something in the where clause for roles in Prisma, the only option is equal
1 Answer
Reset to default 3Currently there's an open request here so equals
is the only available argument.
As a workaround, you can use a raw query as above via prisma.$queryRaw
.
本文标签: javascriptPrismaWHEREcontain clause for array of enumsStack Overflow
版权声明:本文标题:javascript - PRISMA, WHERE-contain clause for array of enums - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745576457a2157048.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论