Suggested way to do nested inserts

In prisma, it is possible to create nested tables (for instance create posts with a user at the same time) like so:
await prisma.user.create({
  name: 'John',
  posts: { createMany: newPosts }
});

Is it correct that the only way to do this in drizzle would be to do something like:
cosnt [{id: userId}] = await db.insert(users).values({ name: 'John' }).returning();

await db.insert(posts).values(newPosts.map(post => ({ ...post, userId })));

unless you generate userId ahead of time manually
Was this page helpful?