const createResult = await prisma.$transaction(async (tx) => {
const personEntry = await tx.person.create({
data: {
...personData
},
})
for (const hobby of personHobbies) {
await tx.person_hobby.create({
data: {
hobby_play_times: {
createMany: {
data: (hobby.playTime ?? []).map((playTime) => ({
...playTime
})),
},
},
},
})
}
return personEntry
})
const createResult = await prisma.$transaction(async (tx) => {
const personEntry = await tx.person.create({
data: {
...personData
},
})
for (const hobby of personHobbies) {
await tx.person_hobby.create({
data: {
hobby_play_times: {
createMany: {
data: (hobby.playTime ?? []).map((playTime) => ({
...playTime
})),
},
},
},
})
}
return personEntry
})