Prisma nested create only giving proper typings one way
Given a Prisma schema like this
Why do I only get proper typings when creating a listing nested in a contactInfo but not the other way around?
model Listing {
id String @id @default(uuid())
author User @relation(fields: [authorId], references: [id])
authorId String @map("author_id")
title String
description String
price Float
address Address @relation(fields: [addressId], references: [id])
addressId String @map("address_id")
contactInfo ContactInfo @relation(fields: [contactInfoId], references: [id])
contactInfoId String @map("contact_info_id")
imageUrls String[] @map("image_urls")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
@@map("listings")
}
model ContactInfo {
id String @id @default(uuid())
author User @relation(fields: [authorId], references: [id])
authorId String @map("author_id")
name String
email String @unique
phone String
phoneIsPublic Boolean @default(false) @map("phone_is_public")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
listings Listing[]
@@map("contact_infos")
}
model Listing {
id String @id @default(uuid())
author User @relation(fields: [authorId], references: [id])
authorId String @map("author_id")
title String
description String
price Float
address Address @relation(fields: [addressId], references: [id])
addressId String @map("address_id")
contactInfo ContactInfo @relation(fields: [contactInfoId], references: [id])
contactInfoId String @map("contact_info_id")
imageUrls String[] @map("image_urls")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
@@map("listings")
}
model ContactInfo {
id String @id @default(uuid())
author User @relation(fields: [authorId], references: [id])
authorId String @map("author_id")
name String
email String @unique
phone String
phoneIsPublic Boolean @default(false) @map("phone_is_public")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
listings Listing[]
@@map("contact_infos")
}
![No description](https://cdn.answeroverflow.com/1168281350411931698/image.png)
![No description](https://cdn.answeroverflow.com/1168281350701330553/image.png)
0 Replies