Rename struct field to match database column
This commit is contained in:
parent
eb5ecd5fb4
commit
43ffa2803f
|
@ -39,7 +39,7 @@ func MainCliLoop(db *sql.DB) {
|
||||||
case "n", "newstorage":
|
case "n", "newstorage":
|
||||||
var storageArea database.StorageArea
|
var storageArea database.StorageArea
|
||||||
storageArea.Name = GetStringResponse("Storage area name:")
|
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)
|
err = logic.CreateStorageArea(db, storageArea)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
break
|
break
|
||||||
|
|
|
@ -30,7 +30,7 @@ func showStorageInfo(w io.Writer, area database.StorageArea) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.Type)
|
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.StorageType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package database
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
|
|
||||||
type StorageArea struct {
|
type StorageArea struct {
|
||||||
Id int
|
Id int
|
||||||
Name string
|
Name string
|
||||||
Type string
|
StorageType string
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllStorageAreas(db *sql.DB) ([]StorageArea, error) {
|
func GetAllStorageAreas(db *sql.DB) ([]StorageArea, error) {
|
||||||
|
@ -20,7 +20,7 @@ func GetAllStorageAreas(db *sql.DB) ([]StorageArea, error) {
|
||||||
|
|
||||||
var area StorageArea
|
var area StorageArea
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := rows.Scan(&area.Id, &area.Name, &area.Type)
|
err := rows.Scan(&area.Id, &area.Name, &area.StorageType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return storageAreas, err
|
return storageAreas, err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func InsertStorageArea(db *sql.DB, storageArea StorageArea) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = insert.Exec(storageArea.Name, storageArea.Type)
|
_, err = insert.Exec(storageArea.Name, storageArea.StorageType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue