2024-07-04 12:32:48 +02:00

35 lines
614 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"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").
Unique(),
field.String("email").
Unique(),
field.String("password").
Sensitive(),
field.Enum("role").
Values("owner", "admin", "user", "visitor"),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("teams", Team.Type),
edge.To("projects", Project.Type),
}
}