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",
},
});
For the above schema, when creating the data, type checker shows error:
It shows the same error even without creating nested record: