IgniteHost
IgniteHost
PPrisma
Created by IgniteHost on 12/7/2024 in #help-and-questions
Property 'xxx' is missing in type with relation
Hello, I am new to the prisma ecosystem and I am having a hard time understanding how it works. Here is my current .prisma file structure:
model GroupGraphics {
groupId Int @id
mainLogo String
group Group?
}
model GroupQA {
groupId Int @id
question String
answer String
group Group @relation(fields: [groupId], references: [id])
}
model Group {
id Int @id @default(autoincrement())
name String
description String[]
shopUrl String
graphics GroupGraphics @relation(fields: [id], references: [groupId] )
visible Boolean
faq GroupQA[]
}
model GroupGraphics {
groupId Int @id
mainLogo String
group Group?
}
model GroupQA {
groupId Int @id
question String
answer String
group Group @relation(fields: [groupId], references: [id])
}
model Group {
id Int @id @default(autoincrement())
name String
description String[]
shopUrl String
graphics GroupGraphics @relation(fields: [id], references: [groupId] )
visible Boolean
faq GroupQA[]
}
Here is my expected output (on select group)
{
"id": 0,
"graphics": { "mainLogo": "Some Values" },
"faq": [ { "question": "Hello", "answer": "World" } ]
}
{
"id": 0,
"graphics": { "mainLogo": "Some Values" },
"faq": [ { "question": "Hello", "answer": "World" } ]
}
The issue is that when I try to add to the database a new group, I get the following:
entityManager.group.create({
data: {
name: "Name",
description: ["Some Desc", "", ""],
shopUrl: "some-url",
faq: { create: [{ question: "MyQuestion", answer: "MyAnswer"}] },
graphics: { create: { mainLogo: "Some Logo" } } // <- **Property 'groupId' is missing in type '{ mainLogo: string; }' but required in type 'GroupGraphicsCreateWithoutGroupInput'.
}
});
entityManager.group.create({
data: {
name: "Name",
description: ["Some Desc", "", ""],
shopUrl: "some-url",
faq: { create: [{ question: "MyQuestion", answer: "MyAnswer"}] },
graphics: { create: { mainLogo: "Some Logo" } } // <- **Property 'groupId' is missing in type '{ mainLogo: string; }' but required in type 'GroupGraphicsCreateWithoutGroupInput'.
}
});
Can somebody tell me what I am missing exactly ? Thank you
7 replies