Files
ent/examples/traversal/ent/schema/user.go
Ariel Mashraki 4ae7526a65 ent/doc: traversal docs and example
Reviewed By: alexsn

Differential Revision: D17112102

fbshipit-source-id: a4ed3fe82f804631796e4b197dba5f936abdc0fc
2019-08-29 07:31:18 -07:00

33 lines
627 B
Go

package schema
import (
"github.com/facebookincubator/ent"
"github.com/facebookincubator/ent/schema/edge"
"github.com/facebookincubator/ent/schema/field"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.Int("age"),
field.String("name"),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("pets", Pet.Type),
edge.To("friends", User.Type),
edge.From("groups", Group.Type).
Ref("users"),
edge.From("manage", Group.Type).
Ref("admin"),
}
}