Files
ent/examples/o2mrecur/ent/schema/node.go
Ariel Mashraki 3e018277b1 ent/doc: O2M same type example
Reviewed By: alexsn

Differential Revision: D17050185

fbshipit-source-id: ef12cc82ab9bf155713faf94129fd5fe503664e4
2019-08-26 03:18:24 -07:00

29 lines
505 B
Go

package schema
import (
"github.com/facebookincubator/ent"
"github.com/facebookincubator/ent/schema/edge"
"github.com/facebookincubator/ent/schema/field"
)
// Node holds the schema definition for the Node entity.
type Node struct {
ent.Schema
}
// Fields of the Node.
func (Node) Fields() []ent.Field {
return []ent.Field{
field.Int("value"),
}
}
// Edges of the Node.
func (Node) Edges() []ent.Edge {
return []ent.Edge{
edge.To("children", Node.Type).
From("parent").
Unique(),
}
}