관계 설정
model User {
id Int @id @default(autoincrement())
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
author User @relation(fields: [authorId], references: [id])
authorId Int
}트랜잭션
await prisma.$transaction([
prisma.post.create({ data: { title: "Hello" } }),
prisma.user.update({ where: { id: 1 }, data: { postCount: { increment: 1 } } }),
]);
댓글 0