Prisma and TS.
model Product {
id String @id @unique
name String
description String @db.LongText
isSet Boolean @default(false)
isAvailable Boolean @default(false)
productLine ProductLine @default(NONE)
shopName ShopName @default(MARTIALARTS)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
prices Price[]
}
model Price {
productId String
countryCode String
price Decimal @db.Decimal(10, 2)
discount Decimal? @db.Decimal(10, 2)
product Product @relation(fields: [productId], references: [id])
currency Currency @relation(fields: [countryCode], references: [countryCode])
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
@@id([productId, countryCode])
@@index([productId])
@@index([countryCode])
}
model Currency {
countryCode String @id @unique
currencyName String
taxRate Decimal @db.Decimal(10, 2)
countryName String
shippingPrice Decimal @default(6) @db.Decimal(10, 2)
Price Price[]
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
}
Now When I am using my Query I am using all includes these are generated correctly with all data. Now I map over a list of products. But I cant asign the value Product as Type to the given element. My next problem is, how can I pass this value to another component which type should I use ? None is working. I just want full typesafety with TS but I am not able to pass a simple query with 2 nested relations to it