Typeorm transaction without release

Viewed 274

What happens if I start a commit transaction but don't release it?

Example:

const connection = getConnection()
const runner = connection.createQueryRunner()

await runner.connect()
await runner.startTransaction()

try {
  const repository = connection.getRepository(PostgresUserEntity)
  const instance = repository.create({ username: 'john doe' })

  await runner.manager.save(instance)
 // imagine others operations...

  await runner.commitTransaction()
} catch () {
  await runner.rollbackTransaction()
}

Docs don't explain details about this

https://typeorm.io/#/transactions/using-queryrunner-to-create-and-control-state-of-single-database-connection

0 Answers
Related