Prisma
Summary
This documents how prisma is integrated with Dendron
Architecture
- prisma is a dependency of Dendron Engine
- during the
buildstep, we callbuildPrismaClient"buildPrismaClient": "yarn prisma generate && node copyPrismaClient.js"- this will call
prisma generatewhich will create the.nodeplatform specific bindings and add it tosrc/drivers/generated-prisma-client(this is so typescript can recognize and get types from it) - this will also copy over the files into
lib/drivers/generated-prisma-client(this is so that our javascript code can actuall import the client)
- this will call
- during bundling, webpack ignores
./generated-prisma-clientvia the config-
WARNING: we match the string literal
./generated-prisma-clientwhich means that any imports of./generated-prisma-clientmuch match this string EXACTLY
-
- after bundling, we copy the
generated-prisma-clientpackage from Dendron Engine to thedistfolder where webpack outpus the javascript - running
vsce packagezips everything up so that its ready for deployment
File Layout
- src/
- drivers/
- generated-prisma-client/
- index.js
// native bindings
- *.node
Schema
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "darwin-arm64", "darwin", "windows", "debian-openssl-1.1.x"]
output = "./../src/drivers/generated-prisma-client"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model Note {
id String @id
fname String?
title String?
vault DVault @relation(fields: [dVaultId], references: [id])
updated Int?
created Int?
stub Boolean?
dVaultId Int
@@index([id], map: "idx_notes_id")
}
model DVault {
id Int @id @default(autoincrement())
name String? @unique
fsPath String
wsRoot String
workspace Workspace @relation(fields: [wsRoot], references: [wsRoot], onDelete: Cascade)
Note Note[]
@@unique([wsRoot, fsPath])
}
model Workspace {
wsRoot String @id @unique
prismaSchemaVersion Int
vaults DVault[]
}
Lookup
- original pr
- the
prisma/schema.prismafile is responsible for prisma configuration
Backlinks