47ng / 47ng/prisma-field-encryption

Fields that are selected through include are returned as cyphertext

Offen
#92 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
306
Forks
40
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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])
}

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.