Prisma Repo pattern
Unanswered
Maltese posted this in #help-forum
MalteseOP
Hello, folks! I am trying to use the Repository pattern with prisma, but I am facing type errors and wrong type inheritance
For this code:
I am getting
Instead of:
For this code:
class PostModel {
static async findMany(obj?: Prisma.PostFindManyArgs) {
return await db.post.findMany(obj);
}
}
await PostModel.findUnique({
where: {
id: params.id,
},
include: {
author: true,
}
})I am getting
Post | nullInstead of:
Post & {author: Author} | null