esponges
esponges
TTCTheo's Typesafe Cult
Created by esponges on 11/4/2022 in #questions
Hoisting in nextJs
5 replies
TTCTheo's Typesafe Cult
Created by esponges on 10/29/2022 in #questions
trpc v10 (but not v9) stuck loading any query
disregard my post. It's working in my other laptop. Maybe related to my node version? no idea.
1 replies
TTCTheo's Typesafe Cult
Created by esponges on 10/28/2022 in #questions
Any example repo with advanced use of t3
I'd mainly would like to see trpc-query mutation side effects (https://tanstack.com/query/v4/docs/guides/mutations?from=reactQueryV3&original=https://react-query-v3.tanstack.com/guides/mutations#mutation-side-effects) & project organization. I was searching around in github but found mostly basic examples.
1 replies
TTCTheo's Typesafe Cult
Created by esponges on 10/23/2022 in #questions
Spot the Prisma relation error?
Hey guys, I'm trying to add a @relation in prisma but I'm forced to create use an array of elements for the model (one to many) and I want a one to one relationship here.
model OrderDetail {
id String @id @default(cuid())
orderId String
address String
city String
country String
postalCode String
phone String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
}

model Order {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
orderItems OrderItem[]
orderDetails OrderDetail[] // don't want this to be an array
}
model OrderDetail {
id String @id @default(cuid())
orderId String
address String
city String
country String
postalCode String
phone String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
}

model Order {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
orderItems OrderItem[]
orderDetails OrderDetail[] // don't want this to be an array
}
More info in the SO question: https://stackoverflow.com/questions/74167803/why-prisma-forces-me-to-have-an-array-in-a-relationship?noredirect=1#comment130948143_74167803 or even more in the repo :). https://github.com/esponges/t3-ecommerce
1 replies
TTCTheo's Typesafe Cult
Created by esponges on 10/21/2022 in #questions
TRPC mutation example with relationships
Hey, I'm building an e-commerce site as a side project but I'm not sure how to make use of the mutation method with relationships. Have anyone seen an example that handles these cases? This would be step where the user has entered his details in a form and I already have the Product(s) in the cart global state. My prisma schema is something like this:
model OrderItem {
id String @id @default(cuid())
quantity Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
orderId String
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
productId String
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
}

model OrderDetail {
id String @id @default(cuid())
orderId String
address String
city String
country String
postalCode String
phone String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
}

model Order {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
orderItems OrderItem[]
orderDetails OrderDetail[] // can't get not to be an array??
}
model OrderItem {
id String @id @default(cuid())
quantity Int
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
orderId String
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
productId String
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
}

model OrderDetail {
id String @id @default(cuid())
orderId String
address String
city String
country String
postalCode String
phone String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
}

model Order {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
orderItems OrderItem[]
orderDetails OrderDetail[] // can't get not to be an array??
}
I don't have any type errors like this but I'm wondering if I'm in the right direction. The source is here in case if you want to see the rest of the code https://github.com/esponges/t3-ecommerce
1 replies
TTCTheo's Typesafe Cult
Created by esponges on 10/6/2022 in #questions
Why I'm getting this TRPCClient error when navigating?
5 replies