P
Prisma•7mo ago
Samar

[Help]Prisma ORM with Express and TypeScript. Trying to use include.

I'm using Prisma ORM with Express and TypeScript and I'm trying to use include with findMany query. I'm currently getting a typescript error. export const getAllCategories = async (req: Request, res: Response) => { const categories = await prisma.category.findMany({ include: { products: true }, }); return res.json({ status: 200, data: categories, msg: "Successfully Fetched All Categories", }); }; error: Object literal may only specify known properties, but 'products' does not exist in type 'CategoryInclude<DefaultArgs>'. Did you mean to write 'procucts'?ts(2561) (property) products: boolean this is on the products: , inside include. This is my schema: // Define the Category model model Category { cid Int @id @default(autoincrement()) name String description String? procucts Product[] } // Define the Product model model Product { pid Int @id @default(autoincrement()) name String description String price Float salePrice Float? image String[] category Category @relation(fields: [categoryId], references: [cid]) categoryId Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
Solution:
Hi @Samar 👋 You have a typo in your Category model. You defined a field procucts instead of products. Can you update the field and then regenerate the Prisma Client by running npx prisma generate....
Jump to solution
3 Replies
Solution
RaphaelEtim
RaphaelEtim•7mo ago
Hi @Samar 👋 You have a typo in your Category model. You defined a field procucts instead of products. Can you update the field and then regenerate the Prisma Client by running npx prisma generate.
Samar
SamarOP•7mo ago
Oops. Thank You.
RaphaelEtim
RaphaelEtim•7mo ago
You're most welcome
Want results from more Discord servers?
Add your server