Skip to content

Commit

Permalink
redesigned the schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Celesca committed Nov 24, 2024
1 parent 40b0769 commit d23622b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/controllers/personalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,44 @@ export const personalController = new Elysia({ prefix: "/personal" })
userID: t.String(),
personalID: t.Number(),
}),
})

// Update personal information for a user
.put("/update", async ({ body, error }) => {
const { userID, personalID } = body;

// Check if the user exists
const user = await prisma.user.findUnique({
where: { UserID: userID },
});

if (!user) {
return error(404, "User not found");
}

// Find the UserPersonal of the user
const personal = await prisma.userPersonal.findUnique({
where: { UserID: userID, PersonalID: personalID },
});

if (!personal) {
return error(404, "Personal information not found");
}

// Update the personal information
const updatedPersonal = await prisma.userPersonal.update({
where: { UserID: userID, PersonalID: personalID },
data: {
UserID: userID,
PersonalID: personalID,
},
});

return updatedPersonal;
},
{
body: t.Object({
userID: t.String(),
personalID: t.Number(),
}),
})

0 comments on commit d23622b

Please sign in to comment.