mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: dlvhdr Differential Revision: D17149835 fbshipit-source-id: 0977cd12a30c2396475803af1f72c31230ea97c1
37 lines
834 B
Go
37 lines
834 B
Go
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
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"),
|
|
}
|
|
}
|