#noob question about cart Product[]

39 messages · Page 1 of 1 (latest)

brisk wyvern
river wave
#

Hi vmathi The relation should exist. Can you share with us the js part to see if it is right?

Also, make sure you updated and push this new change to your db (new migration if not existing)

brisk wyvern
#

in the case the user exists, I try to "user.cart" but that makes sense that it doesn't exist

river wave
# brisk wyvern
const user = await prisma.user.findUnique({
 where: { email },
 include: { cart: true }
});
#

It should fix your issue

brisk wyvern
river wave
brisk wyvern
river wave
# brisk wyvern

Have you correctly migrated your schema? Because i can only see that

brisk wyvern
#

I'm doing "npx prisma db push"

#

i guess it's the same? i can see all the tables in supabase

#

i have the prisma client updated and i'm also generating zod schemas

#

for trpc

#

so you insist I should have user.cart? even when the relation is null

#

i think that's the problem, the prisma type will always be null too, doesn't matter if there's a relation or not

river wave
brisk wyvern
#

i seeee

river wave
#

Create a new migration and it should solve the issue

#

The push command doesn't apply locally, i don't think so, that's why it is different

brisk wyvern
#

is this correct?
Prisma Migrate provides a more granular control over the migration process, allowing you to define and manage migration files manually. Prisma db push, on the other hand, is a higher-level command that simplifies the migration process by automatically detecting changes in the schema and applying them to the database.

#

gpt'ing

river wave
brisk wyvern
#

got the same error

#

😛

#

"Property 'cart' does not exist on type '{ userId: string; admin: boolean | null; name: string | null......."

river wave
brisk wyvern
#

somehow made the user router work

#

now switching the product router from nosql to sql

brisk wyvern
#

for example this work great, it includes the relation:

river wave
#

It should be the same with the cart property instead of owned_products

river wave
#

Just got a new idea: did you regenerate the client? @brisk wyvern

#

Not sure if Prisma does it automatically after a migration

brisk wyvern
#

its' complicated, i have a guest user that didn't have the cart field

#

so with an if i grabbed the registered user and worked