Skip to content

Commit

Permalink
feat(meeting): ✨ setting up new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussinSa committed Feb 5, 2024
1 parent 4c2eda8 commit 4057d3d
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
97 changes: 97 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ model User {
receiveEmail Boolean @default(true)
token String? @unique
meetingsHosted Meeting[] @relation("hostId")
groups GroupMembers[]
notifications UserNotifications[]
generalAvailability GeneralAvailability[]
meetingSpecificAvailability MeetingSpecificAvailability[]
meetingParticipants MeetingParticipants[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand All @@ -50,3 +57,93 @@ model Session {
@@index([user_id])
}

model Meeting {
id String @id @default(uuid())
title String
description String?
startTime Int
endTime Int
location String?
hostId String
created_at Int
host User @relation("hostId", fields: [hostId], references: [id])
participants MeetingParticipants[]
groups MeetingGroups[]
agendaItems MeetingAgendaItems[]
MeetingSpecificAvailability MeetingSpecificAvailability[]
}

model Groups {
id String @id @default(uuid())
name String
description String?
created_at Int
members GroupMembers[]
meetings MeetingGroups[]
}

model GroupMembers {
userId String
groupId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
group Groups @relation(fields: [groupId], references: [id], onDelete: Cascade)
@@id([userId, groupId])
}

model MeetingParticipants {
meetingId String
userId String
status String
meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([meetingId, userId])
}

model MeetingGroups {
meetingId String
groupId String
meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade)
group Groups @relation(fields: [groupId], references: [id], onDelete: Cascade)
@@id([meetingId, groupId])
}

model MeetingAgendaItems {
id String @id @default(uuid())
meetingId String
title String
description String?
duration Int?
meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade)
}

model UserNotifications {
id String @id @default(uuid())
userId String
message String
timestamp Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model GeneralAvailability {
id String @id @default(uuid())
userId String
dayOfWeek Int
startTime Int
endTime Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model MeetingSpecificAvailability {
id String @id @default(uuid())
userId String
meetingId String
date Int
startTime Int
endTime Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade)
}
39 changes: 39 additions & 0 deletions src/routes/meeting-api/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function POST({ request }: { request: Request }) {
const body = await request.json();

try {
// Update a meeting in the database
const updatedMeeting = await prisma.meeting.create({
data: {
title: body.title,
description: body.description,
startTime: body.startTime,
endTime: body.endTime,
location: body.location,
hostId: body.hostId,
created_at: Math.floor(Date.now() / 1000),
},
});
return new Response(
JSON.stringify({ message: "Meeting was updated successfully", updatedMeeting }),
{
status: 200,
headers: {
"Content-Type": "application/json",
},
},
);
} catch (error) {
console.error("error", error);
return new Response(JSON.stringify({ error: "Failed to create the meeting" }), {
status: 500,
headers: {
"Content-Type": "application/json",
},
});
}
}

0 comments on commit 4057d3d

Please sign in to comment.