Skip to content

Commit c13c1cc

Browse files
committed
Add a bit more notes to the example about transactions
1 parent b1a27dd commit c13c1cc

File tree

1 file changed

+2
-2
lines changed
  • examples/realworld-postgres/src

1 file changed

+2
-2
lines changed

examples/realworld-postgres/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async fn register(mut req: Request<PgPool>) -> Response {
5050
let body: RegisterRequestBody = req.body_json().await.unwrap();
5151
let hash = hash_password(&body.password).unwrap();
5252

53-
// Make a new transaction
53+
// Make a new transaction (for giggles)
5454
let pool = req.state();
5555
let mut tx = pool.begin().await.unwrap();
5656

@@ -70,7 +70,7 @@ RETURNING id, username, email
7070

7171
let token = generate_token(rec.id).unwrap();
7272

73-
// Explicitly commit
73+
// Explicitly commit (otherwise this would rollback on drop)
7474
tx.commit().await.unwrap();
7575

7676
#[derive(serde::Serialize)]

0 commit comments

Comments
 (0)