package main import ( "encoding/json"; "fmt"; "os" "floorvisualizer/internal/model" "floorvisualizer/internal/repository" ) func main() { db, _ := repository.Connect("postgres://postgres:dev123456@localhost:5432/floorvisualizer?sslmode=disable") defer db.Close() db.Exec("DELETE FROM products") files, _ := os.ReadDir("data/products") total := 0 for _, f := range files { if f.IsDir() { continue } data, _ := os.ReadFile("data/products/" + f.Name()) var prods []model.Product json.Unmarshal(data, &prods) repository.InsertProducts(db, prods) total += len(prods) fmt.Printf(" %s: %d\n", f.Name(), len(prods)) } fmt.Printf("\nDone! %d products\n", total) }