I am trying (desperately) to filter the pads based on the users email. For example if you log in with google as johndoe@gmail.com than it will fetch the pads for that specific user. I am using firebase for the authentication and if the user is a new user (getAdditionalUserInfo(userResponse).isNewUser) I save the email to the database. Right now the response is empty no matter what user I am signed in as even though I have created many pads. Any tips on if I am doing this right would be helpful. I am new to using stack overflow as a user so any helpful tips on that would be good as well.
here is the code to get the pads:
async pads(email: string): Promise<ScratchPad[]> {
return this.prisma.scratchPad.findMany({
where: {
User: {
email: email,
},
},
});
}
here is the code to get the user:
async getUser(email: string): Promise<User | null> {
return this.prismaService.user.findUnique({
where: { email: email },
include: {
pads: true,
},
});
}
if you need more code please let me know but I am going to leave it at that since this question is getting large.
edit:
here is the prisma code as well:
model User {
id Int @id @default(autoincrement())
email String @unique
pads ScratchPad[]
}
model ScratchPad {
id Int @id @default(autoincrement())
content String
User User? @relation(fields: [userId], references: [id])
userId Int?
}