File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -812,15 +812,24 @@ It is therefore recommended using the `RowIterator` API instead,
812
812
which has explicit error handling:
813
813
814
814
` ` ` swift
815
+ // option 1 : convert results into an Array of rows
815
816
let rowIterator = try db.prepareRowIterator(users)
816
817
for user in try Array (rowIterator) {
817
818
print (" id: \( user[id]), email: \( user[email])" )
818
819
}
819
820
820
- / // or using ` map()`
821
+ /// option 2 : transform results using ` map()`
821
822
let mapRowIterator = try db.prepareRowIterator(users)
822
823
let userIds = try mapRowIterator.map { $0 [id] }
823
824
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
+ }
824
833
```
825
834
826
835
### Plucking Rows
You can’t perform that action at this time.
0 commit comments