mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-17 06:08:42 +00:00
39 lines
681 B
Go
39 lines
681 B
Go
|
package schema
|
||
|
|
||
|
import (
|
||
|
"entgo.io/ent"
|
||
|
"entgo.io/ent/schema/edge"
|
||
|
"entgo.io/ent/schema/field"
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
// 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.UUID("id", uuid.UUID{}).
|
||
|
Default(uuid.New),
|
||
|
field.String("name").
|
||
|
NotEmpty(),
|
||
|
field.String("email").
|
||
|
NotEmpty().
|
||
|
Unique(),
|
||
|
field.String("password").
|
||
|
NotEmpty().
|
||
|
Sensitive(),
|
||
|
field.Bool("is_superuser").
|
||
|
Default(false),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Edges of the User.
|
||
|
func (User) Edges() []ent.Edge {
|
||
|
return []ent.Edge{
|
||
|
edge.To("auth_tokens", AuthTokens.Type),
|
||
|
}
|
||
|
}
|