Added some structs to represent a few database tables.

This commit is contained in:
2021-09-02 22:02:16 -05:00
parent 5fb10685ba
commit 6e4f7044e8
+26
View File
@@ -5,10 +5,36 @@ import (
_ "encoding/json"
"fmt"
"net/http"
"time"
_ "github.com/lib/pq"
)
type Item struct {
Id int32 `json:"id"`
Name int32 `json:"name"`
ValueCents int32 `json:"valueCents"`
PurchaseCostCents int32 `json:"purchasedCostCents"`
Aquired time.Time `json:"aquired"`
Description string `json:"description"`
Notes string `json:"notes"`
SoldForCents int32 `json:"soldForCents"`
SoldTo string `json:"soldTo"`
Category Category `json:"category"`
Subcategory Subcategory `json:"subcategory"`
}
type Category struct {
Id int32 `json:"id"`
Name string `json:"name"`
}
type Subcategory struct {
Id int32 `json:"id"`
Name string `json:"name"`
CategoryId int32 `json:"categoryId"`
}
func main() {
http.HandleFunc("/data", get)
err := http.ListenAndServe(":8080", nil)