36 lines
636 B
Go
36 lines
636 B
Go
|
package schema
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"github.com/facebook/ent"
|
||
|
"github.com/facebook/ent/schema/edge"
|
||
|
"github.com/facebook/ent/schema/field"
|
||
|
)
|
||
|
|
||
|
// Event holds the schema definition for the Event entity.
|
||
|
type Event struct {
|
||
|
ent.Schema
|
||
|
}
|
||
|
|
||
|
// Fields of the Event.
|
||
|
func (Event) Fields() []ent.Field {
|
||
|
return []ent.Field{
|
||
|
field.Time("created_at").
|
||
|
Default(time.Now),
|
||
|
field.Time("updated_at").
|
||
|
Default(time.Now),
|
||
|
field.Time("time"),
|
||
|
field.String("serialized").MaxLen(4095),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Edges of the Event.
|
||
|
func (Event) Edges() []ent.Edge {
|
||
|
return []ent.Edge{
|
||
|
edge.From("owner", Alert.Type).
|
||
|
Ref("events").
|
||
|
Unique(),
|
||
|
}
|
||
|
}
|