prisma-field-encryption
prisma-field-encryption copied to clipboard
Fields that are selected through include are returned as cyphertext
When doing a query which includes encrypted fields, rather than selecting them directly, the field will return encrypted. Example of my prisma schema:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
generator fieldEncryptionMigrations {
provider = "prisma-field-encryption"
output = "./migrations"
// Optionally opt-in to concurrent model migration.
// Since this can cause timeouts and performance issues,
// it's off by default, and models are updated sequentially.
concurrently = true
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
enum Role {
USER
ADMIN
}
model User {
id String @id @default(cuid()) @map("_id")
accountId String @unique
email String /// @encrypted?mode=strict
role Role @default(USER)
subscriptions Subscription[] @relation("subscriptions")
createdSubscriptions Subscription[] @relation("createdSubscriptions")
}
model Subscription {
id String @id @default(cuid()) @map("_id")
name String
paymentUrl String
expiresOn DateTime
customerId String
customer User @relation("subscriptions", fields: [customerId], references: [id])
adminId String
admin User @relation("createdSubscriptions", fields: [adminId], references: [id])
}