datasource db {
  provider = "sqlite"
  url      = "file:db.sqlite"
}

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

model Blog {
  id        Int      @default(autoincrement()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name      String
  viewCount Int      @default(0)
  posts     Post[]
  authors   User[]
}

model User {
  id        Int      @default(autoincrement()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  name      String?
  posts     Post[]
  blogId    Int?
  blog      Blog?    @relation(fields: [blogId], references: [id])
  rating    Float
}

model Post {
  id     Int    @default(autoincrement()) @id
  title  String
  tags   Tag[]  @relation(references: [id])
  blogId Int?
  blog   Blog?  @relation(fields: [blogId], references: [id])
  User   User?  @relation(fields: [userId], references: [id])
  userId Int?
}

model Tag {
  id    Int    @default(autoincrement()) @id
  label String
  posts Post[] @relation(references: [id])
}
