Nested Queries in Prisma are better than making multiple separate queries, because they create a more optimal SQL query.
Example of a nested query in Prisma
await prisma.note.create({
data: {
id: 'd27a197e',
title: 'Basic Koala Facts',
content:
'Koalas are found in the eucalyptus forests of eastern Australia. They have grey fur with a cream-coloured chest, and strong, clawed feet, perfect for living in the branches of trees!',
ownerId: kody.id,
images: {
create: [
{
altText: 'an adorable koala cartoon illustration',
contentType: 'image/png',
blob: await fs.promises.readFile(
'./tests/fixtures/images/kody-notes/cute-koala.png',
),
},
{
altText: 'a cartoon illustration of a koala in a tree eating',
contentType: 'image/png',
blob: await fs.promises.readFile(
'./tests/fixtures/images/kody-notes/koala-eating.png',
),
},
],
},
},
})