goipam/db/addresses.go

32 lines
462 B
Go
Raw Permalink Normal View History

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