-
-
Notifications
You must be signed in to change notification settings - Fork 137
type check error when creating record for implicit many-to-many model #2534
Copy link
Copy link
Open
Description
model Post {
id Int @id @default(autoincrement())
title String
categories Category[]
}
model Category {
id Int @id @default(autoincrement())
name String
posts Post[]
}For the above schema, when creating the data, type checker shows error:
Property 'id' is missing in type '{ name: string; }' but required in type 'Omit<CreateWithFKInput<SchemaType, "Category", { dialect: SqliteDialect; }>, "posts">'.ts(2322) const post = await db.post.create({
data: {
title: "How to become a butterfly",
categories: {
create: [{ name: "Life" }, { name: "Transformation" }],
},
},
});It shows the same error even without creating nested record:
await db.post.create({
data: {
title: "How to become a butterfly",
},
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels