Have I got inserts right for MySQL(Planetscale)?

I'm switching over to Drizzle from Prisma, just wanted to make sure I have inserts written correctly, specifically inserts with relationships, for example, this is inserting a business with an associated businessAddress, does that look right? Ctx is just TRPC.

await ctx.db.transaction(async (tx) => {
  await tx.insert(businessTable).values({
    businessName: input.businessName,
    description: input.description,
    email: input.email,
    hasAgreedTerms: input.hasAgreedTerms,
    userId: ctx.userId
  });

  const business = await tx.select({ businessId: businessTable.businessId     }).from(businessTable).where(eq(businessTable.userId, ctx.userId));
  
  const businessId = business[0]?.businessId;

  await tx.insert(businessAddressTable).values({
    addressOne: input.addressOne,
    addressTwo: input.addressTwo,
    city: input.city,
    postCode: input.postCode,
    countryId: input.countryId,
    businessId: businessId
  });
});


Appreciate the input, thanks.
Was this page helpful?