Samar
Samar
PPrisma
Created by Samar on 5/31/2024 in #help-and-questions
[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 }
6 replies