Skip to content

Commit 2b0abb0

Browse files
author
Confile
committed
Insert alternative transaction statement
1 parent 8215629 commit 2b0abb0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Documentation/Index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,16 @@ db.transaction()
902902
&& db.commit() || db.rollback()
903903
```
904904

905+
The former statement can also be written as
906+
``` swift
907+
db.transaction { _ in
908+
for obj in objects {
909+
stmt.run(obj.email)
910+
}
911+
return .Commit || .Rollback
912+
}
913+
```
914+
905915
> _Note:_ Each statement is captured in an auto-closure and won’t execute till the preceding statement succeeds. This means we can use the `lastInsertRowid` property on `Database` to reference the previous statement’s insert [`ROWID`][ROWID].
906916

907917

0 commit comments

Comments
 (0)