Muhammad Ahmad
04/11/2022, 1:07 PMmodel Profile {
id String @id @default(cuid())
name String
address String
image blob
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}
model Token {
id String @id @default(cuid())
profile_id Profile[]
featured_status Boolean
category String
file blob
description String
info String
type String
last_selling_price Float
ownership_chain String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}
Hello I am trying to add one to many relation (one profile can have many tokens) but I think this isn't correct. Also code editor giving me red lines on blob type and bytea for storing images.Nurul
04/12/2022, 6:21 AMbytea
type but I cannot see any field having bytea type in the above schema.
For the one to many relations you are looking for something like this:
model Profile {
id String @id @default(cuid())
name String
address String
image blob
created_at DateTime @default(now())
updated_at DateTime @updatedAt
Token Token[]
}
model Token {
id String @id @default(cuid())
featured_status Boolean
category String
file blob
description String
info String
type String
last_selling_price Float
ownership_chain String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
profileId String
profile Profile? @relation(fields: [profileId], references: [id])
}
Dimitri Borgers
05/27/2022, 4:43 AMNurul
05/27/2022, 10:11 AM