Files
main.tsmain
What you'll learn
- Run several writes as one transaction with dataSource.transaction() and explain why only the manager it hands over is inside it
- Write the explicit QueryRunner form: connect, start, commit or roll back, release in finally
- Register an entity subscriber as a provider and change an entity in a before hook, whoever inserts it
Press Run tests to start the app. Its log appears here.Graded endpoints
The subscriber's beforeInsert tidied the name before the row was written
A second cat
An owner
Three writes committed together: adopted, owned, registered
One line, written in the same transaction
The owner lookup threw inside the transaction
The first write, marking her adopted, was rolled back with the rest
Still one line
An adopted cat is refused with a 409 before any write
The QueryRunner transaction deleted the register line and freed the cat, then committed
Empty
The check inside the transaction threw, the transaction rolled back, the runner was released, and the error reached the client
The lookup inside the runner's transaction threw a 404