Skip to main content Svelte Highlight v7.21.1

Prisma language preview

1. Datasource and generator

datasource and generator blocks
horizon-dark
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
atom-one-dark
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
github-dark
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
dracula
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
nord
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}
github
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

2. Model fields

scalar types, ?, [], @attributes, and a field named type
horizon-dark
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}
atom-one-dark
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}
github-dark
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}
dracula
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}
nord
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}
github
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  type      String
  role      Role     @default(USER)
  posts     Post[]
  createdAt DateTime @default(now())

  @@map("users")
}

3. Relations and enums

@relation, @@index, and enum Role
horizon-dark
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}
atom-one-dark
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}
github-dark
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}
dracula
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}
nord
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}
github
model Post {
  id       Int    @id @default(autoincrement())
  title    String
  author   User   @relation(fields: [authorId], references: [id])
  authorId Int

  @@index([authorId])
}

enum Role {
  USER
  ADMIN
}

4. Comments

// line comments and /// doc comments
horizon-dark
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}
atom-one-dark
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}
github-dark
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}
dracula
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}
nord
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}
github
// Core identity model
model User {
  id    Int    @id @default(autoincrement())
  email String @unique

  /// The user's display name, shown in the UI
  name String?
}