Hello Why prisma cannot create record and say you...
# orm-help
k
Hello Why prisma cannot create record and say you did nit set the required field even due I have been set it? and Why it says I have to fill a
relation field
?
Copy code
model Country {
  id                   Int     @id @default(autoincrement())
  // Country Code Alphabet 3
  cca3                 String  @unique() @db.VarChar(3)
 
  states               State[]
  capital              City?   @relation(name: "country_capital")
 
  @@map("countries")
}

model State {
  id                   Int     @id @default(autoincrement())
  // State Code Alphabet 3
  sca3                 String  @db.VarChar(3)
  countryId            Int

  belongsToCountry     Country @relation(fields: [countryId], references: [id], map: "belongs_to_country")

  @@index([sca3])
  @@map("states")
}
Any thought on this?
😀 1
✅ 1
a
It is missing the id for the connect
That looks like Prsima SaaS. no idea then 😄
🙌 1
r
Hi @Kasir Barati In your `State`model you have a
required
relationship between
State
and `Country`:
Copy code
belongsToCountry     Country @relation(fields: [countryId], references: [id], map: "belongs_to_country")
This means that when you create a
State
you need to associate it to a country.
The second issue I think is that it's expecting the
cca3
to be in the
belongsToCountry
but since you haven;t specified anything at all, it's complaining.
✅ 1