79127143

Date: 2024-10-25 19:53:37
Score: 1.5
Natty:
Report link

The best solution I'm aware of turned out to be using a transaction, which allows me much of the benefits as if this were a single query:

await db.transaction(async (tx) => {
  const [user] = await tx.insert(users)...
  const [settings] = await tx.insert(settings).values({ user_id: user.id})
})
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: ivo