Jyn
10/02/2022, 5:03 AMmodel Stage {
id String @id @default(cuid())
code String @unique
createdAt DateTime? @default(now())
rewards Reward[]
}
type Reward {
item_code String
count Int
}
I want to make my schema like this, but an error appears:
Error validating: Composite types are not supported on Postgres.
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
I don’t wanna make Reward
as a table(model in schema), since it is very small pieces. What i tried instead is
1. Make It Together
model Stage {
id String @id @default(cuid())
code String @unique
createdAt DateTime? @default(now())
reward_item_codes String[]
reward_item_counts Int[]
}
Probleme: i need to always check the lengths of those are equal.
2. Use Json
model Stage {
id String @id @default(cuid())
code String @unique
createdAt DateTime? @default(now())
rewards Json
}
probleme: Unhappy that i need to make json converter at each server&front.
What do you bros usually solve these kinda mundane problem in Prisma?
Appreciate your ideas,Nurul
10/10/2022, 2:54 PM