improve integration with record package
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"code.aneur.in/go/record"
|
||||
)
|
||||
|
||||
// https://www.sqlite.org/lang_select.html
|
||||
@@ -123,6 +125,24 @@ func (q *SelectQuery) Query() (*sql.Rows, error) {
|
||||
return nil, ErrNoDatabase
|
||||
}
|
||||
|
||||
func (q *SelectQuery) QueryRecord() (record.Record, error) {
|
||||
rows, err := q.Query()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ScanOneRecord(rows)
|
||||
}
|
||||
|
||||
func (q *SelectQuery) QueryRecords() ([]record.Record, error) {
|
||||
rows, err := q.Query()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ScanRecords(rows)
|
||||
}
|
||||
|
||||
func (q *SelectQuery) QueryRow() *sql.Row {
|
||||
if q.DB != nil {
|
||||
if q.Ctx != nil {
|
||||
|
||||
Reference in New Issue
Block a user