Skip to content

Commit

Permalink
chore: add schema for prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
ayusshrathore committed Jun 5, 2023
1 parent 87748d5 commit ad6ad71
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit ad6ad71

Please sign in to comment.