TinySkin/db/ent/schema/user.go
2023-09-03 15:59:37 +08:00

33 lines
706 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"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("email").Unique(),
field.String("password"),
field.String("salt"),
field.Int("state"),
field.Int64("reg_time"),
}
}
// Edges of the User.
func (User) Edges() []ent.Edge {
return []ent.Edge{
edge.From("skin", Skin.Type).Ref("user").Annotations(entsql.OnDelete(entsql.Cascade)),
edge.To("profile", UserProfile.Type).Unique().Annotations(entsql.OnDelete(entsql.Cascade)),
}
}