goipam/db/locations.go

31 lines
467 B
Go

package db
import "log"
func (location *Location) Save() error {
if err := conn.Save(location).Error; err != nil {
return err
}
return nil
}
func (location *Location) Delete() error {
if err := conn.Delete(location).Error; err != nil {
return err
}
return nil
}
func CountLocations() int {
var count int64
err := conn.Model(&Location{}).Count(&count)
if err != nil {
count = 0
log.Println("Error counting locations: ")
}
return int(count)
}