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
.