P
Prisma2mo 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
RaphaelEtim2mo 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
Samar2mo ago
Oops. Thank You.
RaphaelEtim
RaphaelEtim2mo ago
You're most welcome
Want results from more Discord servers?
Add your server
More Posts
prisma use middlewareHi I am trying to collect logs for args before query request. However, in case of USE (middleware), Prisma telemetry operation contains unaccounted for timeHi there! I'm looking for a little help understanding something I'm seeing frequently from opentelmePrisma ORM returns two different results from two similar (?) queriesHi everyone ! Could someone help me figure out why this two queries don't return the same result ? UncheckedCreateInput error when trying to create a many to many relationship (likeSermon / likePost)Hello i get the following error when i try to creating a relationship where users can like sermons. Implicite Many-to-Many relationship double primary keyImplicite Many-to-Many relationship with two models, but one of these two models has a double primarmongodb connection randomly unable to connecthttps://github.com/prisma/prisma/discussions/11929#discussioncomment-9600119 Error: MongoDB error SPrisma client doesn't get updated with new columns after db pullAs you can see in the screenshot, there is a `user_auth_token` in the schema that showed up after I npx prisma migrate dev --name init from tutorial not workingOnce I get to the part in the supabase prisma tutorial where I run the command `npx prisma migrate dError Initializing Prisma on ExpoI've created an Expo project which I am trying to connect to Supabase via Prisma, but I get the follDoes Accelerate support MSSQL?Does Prisma Accelerate support MSSQL? I don't know if I set it up right, but I ge the following erro