accountserver/ent/schema/account.go

37 lines
864 B
Go
Raw Normal View History

2024-08-19 13:18:59 +02:00
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"time"
)
// Account holds the schema definition for the Account entity.
type Account struct {
ent.Schema
}
// Fields of the Account.
func (Account) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.UUID{}).Unique().Immutable().Annotations(&entsql.Annotation{Default: "gen_random_uuid()"}),
field.Time("created_at").Default(time.Now).Immutable(),
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
field.String("nickname"),
field.String("name"),
field.Bytes("secret"),
field.Bytes("aes").MinLen(16).MaxLen(32),
field.Bytes("x509"),
}
}
// Edges of the Account.
func (Account) Edges() []ent.Edge {
return []ent.Edge{
edge.To("emails", Email.Type),
}
}