wails-template/things/resource.go
schreifuchs 2b13e5c03a
All checks were successful
build / windows (push) Successful in 2m22s
build / linux (push) Successful in 2m3s
remove sub things and add view
2025-03-07 15:23:33 +01:00

34 lines
527 B
Go

package things
import (
"log"
"wails-template/model"
"gorm.io/gorm"
)
type Service struct {
DB *gorm.DB
}
func (s *Service) NewThing(name string) {
if err := s.DB.Save(&model.Thing{Name: name}).Error; err != nil {
log.Fatal(err)
}
print(name)
}
func (s *Service) GetThings() (things []model.Thing) {
if err := s.DB.Find(&things).Error; err != nil {
log.Fatal(err)
}
return things
}
func (s *Service) DeleteThing(id int) {
if err := s.DB.Delete(model.Thing{}, id).Error; err != nil {
log.Fatal(err)
}
}