tajin_malsou9a
03/28/2022, 2:05 PM/*
* Called to sign-up a new user
*
* @params: email
* password
*
* @returns: "OK": on successfully signing up the user
* "EMAIL_ALREADY_EXISTS_ERROR": if the email is already been used
*/
signUp(input: {
email: string;
password: string;
}): Promise<{ status: "OK"; user: User } | { status: "EMAIL_ALREADY_EXISTS_ERROR" }>;
rp_st
03/28/2022, 2:06 PMtajin_malsou9a
03/28/2022, 2:08 PMtajin_malsou9a
03/28/2022, 2:08 PMrp_st
03/28/2022, 2:09 PMtajin_malsou9a
03/28/2022, 2:44 PMteacher = await prisma.teacherAccount.findMany({where : {userId : userId});
if teacher !== [] : {teacher.role = "teacher"; return teacher;}
student = await prisma.studentAccount.findMany({where : {userId : userId});
if student !== [] : {student.role = "student"; return student;}
admin = await prisma.adminAccount.findMany({where : {userId : userId});
if admin !== [] : {admin.role = "admin"; return admin;}
2- Creating another "account" table that stores shared columns (username, phone number etc...) between the users AND the role column, also creating relation tables for each role between "account" and the associated role table because we can have columns specific for each role.
Which option do you recommend for this case?tajin_malsou9a
03/28/2022, 4:08 PMtajin_malsou9a
03/28/2022, 4:08 PMrp_st
03/28/2022, 4:12 PMrp_st
03/28/2022, 4:12 PMrp_st
03/28/2022, 4:13 PMtajin_malsou9a
03/28/2022, 4:29 PMtajin_malsou9a
03/28/2022, 4:30 PMrp_st
03/28/2022, 4:30 PMtajin_malsou9a
03/28/2022, 4:33 PM