add button to add new image to class closes #15

This commit is contained in:
2024-04-16 14:09:03 +01:00
parent 7d742e7970
commit 3ad07e6ce5
6 changed files with 240 additions and 11 deletions

View File

@@ -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()