mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: alexsn Differential Revision: D17050185 fbshipit-source-id: ef12cc82ab9bf155713faf94129fd5fe503664e4
29 lines
505 B
Go
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(),
|
|
}
|
|
}
|