Rename struct field to match database column

This commit is contained in:
The Magician 2024-08-20 18:50:38 +01:00
parent eb5ecd5fb4
commit 43ffa2803f
3 changed files with 7 additions and 7 deletions

View File

@ -39,7 +39,7 @@ func MainCliLoop(db *sql.DB) {
case "n", "newstorage":
var storageArea database.StorageArea
storageArea.Name = GetStringResponse("Storage area name:")
storageArea.Type = GetStringResponse("Storage area type (Binder/Box):")
storageArea.StorageType = GetStringResponse("Storage area type (Binder/Box):")
err = logic.CreateStorageArea(db, storageArea)
logic.Check(err)
break

View File

@ -30,7 +30,7 @@ func showStorageInfo(w io.Writer, area database.StorageArea) {
return
}
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.Type)
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.StorageType)
return
}

View File

@ -5,7 +5,7 @@ import "database/sql"
type StorageArea struct {
Id int
Name string
Type string
StorageType string
}
func GetAllStorageAreas(db *sql.DB) ([]StorageArea, error) {
@ -20,7 +20,7 @@ func GetAllStorageAreas(db *sql.DB) ([]StorageArea, error) {
var area StorageArea
for rows.Next() {
err := rows.Scan(&area.Id, &area.Name, &area.Type)
err := rows.Scan(&area.Id, &area.Name, &area.StorageType)
if err != nil {
return storageAreas, err
}
@ -39,7 +39,7 @@ func InsertStorageArea(db *sql.DB, storageArea StorageArea) error {
return err
}
_, err = insert.Exec(storageArea.Name, storageArea.Type)
_, err = insert.Exec(storageArea.Name, storageArea.StorageType)
if err != nil {
return err
}