39 lines
784 B
Go
39 lines
784 B
Go
//go:build ignore
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"doormile/config"
|
|
"doormile/db"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func main() {
|
|
_ = godotenv.Load()
|
|
cfg := config.Load()
|
|
db.Connect(cfg)
|
|
if db.DB == nil {
|
|
log.Fatal("no DB")
|
|
}
|
|
type c struct {
|
|
Appcustomerid int
|
|
Firstname string
|
|
Phone string
|
|
Configid int
|
|
Status string
|
|
}
|
|
var rows []c
|
|
db.DB.Raw(`SELECT appcustomerid,firstname,phone,configid,status FROM appcustomers
|
|
WHERE phone IN ('9876543210') OR appcustomerid = 5`).Scan(&rows)
|
|
if len(rows) == 0 {
|
|
fmt.Println("no appcustomer with phone 9876543210, and no id 5")
|
|
}
|
|
for _, r := range rows {
|
|
fmt.Printf(" id=%d name=%q phone=%s configid=%d status=%s\n",
|
|
r.Appcustomerid, r.Firstname, r.Phone, r.Configid, r.Status)
|
|
}
|
|
}
|