Prisma ORM

use Prisma ORM to store data

Setup

Add schemas:

model Comment {
  id        Int      @id @default(autoincrement())
  page      String   @default("default") @db.VarChar(256)
  thread    Int?     @map("threadId")
  author    String   @db.VarChar(256)
  content   Json     @db.Json
  timestamp DateTime @default(now()) @db.Timestamp()
 
  rates Rate[]
 
  @@index([page])
}
 
model Rate {
  userId    String  @db.VarChar(256)
  commentId Int
  like      Boolean
 
  comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
 
  @@id([userId, commentId])
  @@index([commentId])
}
 
model Role {
  userId    String  @id @db.VarChar(256)
  name      String
  canDelete Boolean
}
 
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Add to your Fuma Comment config:

import { createPrismaAdapter } from "@fuma-comment/server/adapters/prisma";
 
const storage = createPrismaAdapter({
  db: prisma,
  auth: "next-auth" | "better-auth",
});

On this page