app/calendar/calendar.go

28 lines
357 B
Go
Raw Normal View History

2021-12-21 11:23:34 +00:00
package calendar
2021-12-21 11:44:27 +00:00
import (
"time"
2021-12-21 11:23:34 +00:00
2021-12-21 11:44:27 +00:00
"github.com/rs/xid"
"github.com/rs/zerolog"
"gorm.io/gorm"
)
2021-12-21 11:23:34 +00:00
2021-12-21 11:44:27 +00:00
var l zerolog.Logger
2021-12-21 11:23:34 +00:00
2021-12-21 11:44:27 +00:00
type Calendar struct {
ID string `gorm:"primaryKey"`
Events []Event
2021-12-21 11:23:34 +00:00
CreatedAt time.Time
UpdatedAt time.Time
}
2021-12-21 11:44:27 +00:00
func (c *Calendar) BeforeCreate(tx *gorm.DB) (err error) {
if c.ID == "" {
c.ID = xid.New().String()
}
return
2021-12-21 11:23:34 +00:00
}