2024-02-14 00:08:14 +01:00
|
|
|
package schema
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"entgo.io/ent"
|
2024-02-14 14:55:41 +01:00
|
|
|
"entgo.io/ent/schema/edge"
|
2024-02-14 00:08:14 +01:00
|
|
|
"entgo.io/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.String("name").
|
|
|
|
|
Default("John doe"),
|
2024-02-14 12:39:10 +01:00
|
|
|
field.Enum("role").
|
|
|
|
|
Values("admin", "user", "visitor"),
|
2024-02-14 00:08:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Edges of the User.
|
|
|
|
|
func (User) Edges() []ent.Edge {
|
2024-02-14 14:55:41 +01:00
|
|
|
return []ent.Edge{
|
|
|
|
|
edge.To("teams", Team.Type),
|
|
|
|
|
}
|
2024-02-14 00:08:14 +01:00
|
|
|
}
|