Files
validator/OmCTF-2025/services/block_game/backend/schema/user.go

35 lines
592 B
Go

package schema
import (
"regexp"
"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("username").
Unique().
Match(regexp.MustCompile(`^\w{1,64}$`)),
field.String("password").
MaxLen(128).
NotEmpty(),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.To("ownedLevels", Level.Type),
edge.To("invitedToLevels", Level.Type),
}
}