Next.js Discord

Discord Forum

Prisma Repo pattern

Unanswered
Maltese posted this in #help-forum
Open in Discord
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:

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  | null

Instead of:
Post & {author: Author} | null

0 Replies