add button to add new image to class closes #15
This commit is contained in:
@@ -29,7 +29,7 @@ type BasePackStruct struct {
|
||||
}
|
||||
|
||||
func (b BasePackStruct) GetHost() string {
|
||||
return b.Host
|
||||
return b.Host
|
||||
}
|
||||
|
||||
func (b BasePackStruct) GetDb() *sql.DB {
|
||||
@@ -315,6 +315,31 @@ func InsertReturnId(c QueryInterface, store interface{}, tablename string, retur
|
||||
return
|
||||
}
|
||||
|
||||
func GetDbVar[T interface{}](c QueryInterface, var_to_extract string, tablename string, args ...any) (*T, error) {
|
||||
db_query, err := c.Prepare(fmt.Sprintf("select %s from %s", var_to_extract, tablename))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer db_query.Close()
|
||||
|
||||
rows, err := db_query.Query(args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
if !rows.Next() {
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
dat := new(T)
|
||||
if err = rows.Scan(dat); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dat, nil
|
||||
}
|
||||
|
||||
func GetDBOnce(db QueryInterface, store interface{}, tablename string, args ...any) error {
|
||||
t := reflect.TypeOf(store).Elem()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user