Have a few of the basic admin pages working after switching to the API+View pattern.
This commit is contained in:
parent
fa7f886a59
commit
2b40d6fdc3
9 changed files with 188 additions and 29 deletions
10
admin/db.go
10
admin/db.go
|
@ -8,8 +8,8 @@ import (
|
|||
sq "github.com/Masterminds/squirrel"
|
||||
)
|
||||
|
||||
func SelectTable(table string, the_type reflect.Type, limit uint64, offset uint64) ([]reflect.Value, error) {
|
||||
var results []reflect.Value
|
||||
func SelectTable(table string, the_type reflect.Type, limit uint64, offset uint64) ([]interface{}, error) {
|
||||
var results []interface{}
|
||||
sql_query, args, err := sq.Select("*").Limit(limit).Offset(offset).From(table).ToSql()
|
||||
if err != nil { return results, err }
|
||||
|
||||
|
@ -18,11 +18,11 @@ func SelectTable(table string, the_type reflect.Type, limit uint64, offset uint6
|
|||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
the_data := reflect.New(the_type)
|
||||
err = rows.StructScan(the_data.Interface())
|
||||
the_data := reflect.New(the_type).Interface()
|
||||
err = rows.StructScan(the_data)
|
||||
if err != nil { return results, err }
|
||||
|
||||
results = append(results, the_data.Elem())
|
||||
results = append(results, the_data)
|
||||
}
|
||||
|
||||
return results, rows.Err()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue