Skip to content

Instantly share code, notes, and snippets.

@kayode-adechinan
Forked from nmchenry01/schema.prisma
Created January 28, 2021 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayode-adechinan/6e2cb344c18fc96ada2183332b6ad298 to your computer and use it in GitHub Desktop.
Save kayode-adechinan/6e2cb344c18fc96ada2183332b6ad298 to your computer and use it in GitHub Desktop.
An example Prisma schema for "Prisma vs. TypeORM"
generator client {
provider = "prisma-client-js"
previewFeatures = ["transactionApi"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Company {
id Int @default(autoincrement()) @id
name String @unique
createdAt DateTime @default(now())
products Product[]
}
model Customer {
id Int @default(autoincrement()) @id
username String @unique
email String @unique
createdAt DateTime @default(now())
products Product[] @relation(references: [id])
}
model Product {
id Int @default(autoincrement()) @id
name String @unique
description String?
createdAt DateTime @default(now())
companyId Int
company Company @relation(fields: [companyId], references: [id])
customers Customer[] @relation(references: [id])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment