#noob question about cart Product[]
39 messages · Page 1 of 1 (latest)
Hi
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)
in the case the user exists, I try to "user.cart" but that makes sense that it doesn't exist
const user = await prisma.user.findUnique({
where: { email },
include: { cart: true }
});
It should fix your issue
yep i did that, I get "Property 'cart' does not exist on type"
In your code, you don't specify any include 🤔
sorry I did when I created the post, I just did it again jus to copy-paste the error
Have you correctly migrated your schema? Because i can only see that
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
It is not the same
i seeee
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
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
It does apply the migrations, but it doesn't create them
got the same error
😛
"Property 'cart' does not exist on type '{ userId: string; admin: boolean | null; name: string | null......."
Have you tried to reload your IDE? Could be a fix
somehow made the user router work
now switching the product router from nosql to sql
just a logic issue(my fault)
for example this work great, it includes the relation:
It should be the same with the cart property instead of owned_products
Sorry, it's hard for me to give you more insight, because using the include should more than enough to make it work
Just got a new idea: did you regenerate the client? @brisk wyvern
Not sure if Prisma does it automatically after a migration