I'm really liking the prisma.<model>.create....
# prisma-client
k
I'm really liking the prisma.<model>.create. It's making my life very easy right now with relationships. But i have a question, if for whatever reason the overall object fails to create, what happens to the
image.connect
and
brand_indusry.createMany
we'd want them to also fail right? I guess its obvious you can't really connect or have a relationship to createMany if nothing is made.
Copy code
const newBrand: Prisma.brandCreateInput = {
            id: uuid(),
            name: payload.name,
            website: payload.website,
            slug: payload.slug,
            image: { connect: { id: payload.image_id } },
            brand_industry: { createMany: { data: industries } },
        };

        const createBrand = await PrismaService.brand.create({
            data: newBrand,
        });
1
r
Hi @Kay Khan - as far as I remember the
create
is done in a transaction so the entire transaction is rolled back meaning the
image
and
brand_industry
records will not be created or affected.
1
k
thanks
👍 1