goipam/db/locations.go

31 lines
467 B
Go
Raw Normal View History

2024-02-22 20:52:37 +01:00
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)
}