How can I use returning values when doing a `batch`?

The documentation tells you how to do batches (which are the only way to do what is essentially a transaction on D1): https://orm.drizzle.team/docs/batch-api

The problem is that I have to run the following statements:

const returned = await db
  .insert(schema.universities)
  .values({ handle: form.data.handle })
  .returning({ id: schema.universities.id });

await db.insert(schema.localizedUniversityNames).values({
  university: returned[0].id,
  languageTag: form.data.languageTag,
  name: form.data.name,
});


As you can see the second one requires the returned id from the previous one to work, and I don't see a way to do this in the batch. What can I do?
Was this page helpful?