Initial version of education content #90

Merged
bvisness merged 23 commits from education into master 2022-09-10 16:29:59 +00:00
1 changed files with 14 additions and 2 deletions
Showing only changes of commit 3067b3fc3e - Show all commits

View File

@ -158,7 +158,11 @@ func QueryOne[T any](
result, hasRow := rows.Next()
if !hasRow {
return nil, NotFound
if readErr := rows.Err(); readErr != nil {
return nil, readErr
} else {
return nil, NotFound
}
}
return result, nil
@ -244,7 +248,11 @@ func QueryOneScalar[T any](
result, hasRow := rows.Next()
if !hasRow {
var zero T
return zero, NotFound
if readErr := rows.Err(); readErr != nil {
return zero, readErr
} else {
return zero, NotFound
}
}
return *result, nil
@ -585,6 +593,10 @@ func (it *Iterator[T]) Next() (*T, bool) {
}
}
func (it *Iterator[T]) Err() error {
return it.rows.Err()
}
// Takes a value from a database query (reflected) and assigns it to the
// destination. If the destination is a pointer, and the value is non-nil, it
// will initialize the destination before assigning.