Files
ersteller/schema/ent/example/ent/schema/group.go
T

35 lines
642 B
Go

package schema
import (
"git.gorlug.de/code/golang/ersteller-lib/schema/ent"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
type Group struct {
ent.Schema
}
func (Group) Mixin() []ent.Mixin {
return []ent.Mixin{
ersteller_ent.TimeMixin{},
}
}
func (Group) Fields() []ent.Field {
return []ent.Field{
field.String("name").Default(""),
}
}
func (Group) Edges() []ent.Edge {
return []ent.Edge{
// Back-reference to users that belong to this group
edge.From("users", User.Type).Ref("group"),
// Back-reference to todos that belong to this group
edge.From("todos", Todo.Type).Ref("group"),
}
}