goipam/db/subnets.go

32 lines
453 B
Go
Raw Normal View History

2024-02-22 20:52:37 +01:00
package db
import (
"log"
)
func (subnet *Subnet) Save() error {
if err := conn.Save(subnet).Error; err != nil {
return err
}
return nil
}
func (subnet *Subnet) Delete() error {
if err := conn.Delete(subnet).Error; err != nil {
return err
}
return nil
}
func CountSubnets() int {
var count int64
err := conn.Model(&Subnet{}).Count(&count)
if err != nil {
count = 0
log.Println("Error counting subnets: ")
}
return int(count)
}