|
|
@@ -112,6 +112,9 @@ func (q *Query) Scan(dest ...interface{}) error {
|
|
|
return iter.Close()
|
|
|
}
|
|
|
|
|
|
+// Iter represents an iterator that can be used to iterate over all rows that
|
|
|
+// were returned by a query. The iterator might send additional queries to the
|
|
|
+// database during the iteration if paging was enabled.
|
|
|
type Iter struct {
|
|
|
err error
|
|
|
pos int
|
|
|
@@ -121,10 +124,19 @@ type Iter struct {
|
|
|
pageState []byte
|
|
|
}
|
|
|
|
|
|
+// Columns returns the name and type of the selected columns.
|
|
|
func (iter *Iter) Columns() []ColumnInfo {
|
|
|
return iter.columns
|
|
|
}
|
|
|
|
|
|
+// Scan consumes the next row of the iterator and copies the columns of the
|
|
|
+// current row into the values pointed at by dest. Scan might send additional
|
|
|
+// queries to the database to retrieve the next set of rows if paging was
|
|
|
+// enabled.
|
|
|
+//
|
|
|
+// Scan returns true if the row was successfully unmarshaled or false if the
|
|
|
+// end of the result set was reached or if an error occurred. Close should
|
|
|
+// be called afterwards to retrieve any potential errors.
|
|
|
func (iter *Iter) Scan(dest ...interface{}) bool {
|
|
|
if iter.err != nil {
|
|
|
return false
|
|
|
@@ -153,6 +165,8 @@ func (iter *Iter) Scan(dest ...interface{}) bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+// Close closes the iterator and returns any errors that happened during
|
|
|
+// the query or the iteration.
|
|
|
func (iter *Iter) Close() error {
|
|
|
return iter.err
|
|
|
}
|