Skip to content

Commit 84a8788

Browse files
committed
Clarify usage
1 parent ab67978 commit 84a8788

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Documentation/Index.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -812,15 +812,24 @@ It is therefore recommended using the `RowIterator` API instead,
812812
which has explicit error handling:
813813
814814
```swift
815+
// option 1: convert results into an Array of rows
815816
let rowIterator = try db.prepareRowIterator(users)
816817
for user in try Array(rowIterator) {
817818
print("id: \(user[id]), email: \(user[email])")
818819
}
819820

820-
/// or using `map()`
821+
/// option 2: transform results using `map()`
821822
let mapRowIterator = try db.prepareRowIterator(users)
822823
let userIds = try mapRowIterator.map { $0[id] }
823824

825+
/// option 3: handle each row individually with `failableNext()`
826+
do {
827+
while let row = try rowIterator.failableNext() {
828+
// Handle row
829+
}
830+
} catch {
831+
// Handle error
832+
}
824833
```
825834

826835
### Plucking Rows

0 commit comments

Comments
 (0)