diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..4438ffe --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,67 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "mongodb" + url = env("DATABASE_URL") +} + +model User { + id String @id @default(auto()) @map("_id") @db.ObjectId + email String? @unique + name String? + username String? @unique + bio String? + emailVerified DateTime? + image String? + coverImage String? + profileImage String? + hashedPassword String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + followingIds String[] @db.ObjectId + hasNotification Boolean? + + posts Post[] + comments Comment[] + notifications Notification[] +} + +model Post { + id String @id @default(auto()) @map("_id") @db.ObjectId + body String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userId String @db.ObjectId + likedIds String[] @db.ObjectId + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + comments Comment[] +} + +model Comment { + id String @id @default(auto()) @map("_id") @db.ObjectId + body String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userId String @db.ObjectId + postId String @db.ObjectId + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + post Post @relation(fields: [postId], references: [id], onDelete: Cascade) +} + +model Notification { + id String @id @default(auto()) @map("_id") @db.ObjectId + body String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userId String @db.ObjectId + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} \ No newline at end of file