generator client { provider = "prisma-client-js" } datasource db { provider = "sqlite" url = env("DATABASE_URL") } model Note { id String @id @default(cuid()) title String content String type String @default("note") isFavorite Boolean @default(false) isPinned Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt tags NoteTag[] backlinks Backlink[] @relation("BacklinkTarget") outbound Backlink[] @relation("BacklinkSource") } model Tag { id String @id @default(cuid()) name String @unique notes NoteTag[] } model NoteTag { noteId String tagId String note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade) @@id([noteId, tagId]) } model Backlink { id String @id @default(cuid()) sourceNoteId String targetNoteId String sourceNote Note @relation("BacklinkSource", fields: [sourceNoteId], references: [id], onDelete: Cascade) targetNote Note @relation("BacklinkTarget", fields: [targetNoteId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) @@unique([sourceNoteId, targetNoteId]) }