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

35 lines
644 B
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// UserProfile holds the schema definition for the UserProfile entity.
type UserProfile struct {
ent.Schema
}
// Fields of the UserProfile.
func (UserProfile) Fields() []ent.Field {
return []ent.Field{
field.String("name"),
field.String("uuid"),
}
}
// Edges of the UserProfile.
func (UserProfile) Edges() []ent.Edge {
return []ent.Edge{
edge.From("user", User.Type).Ref("profile").Required().Unique(),
}
}
func (UserProfile) Indexes() []ent.Index {
return []ent.Index{
index.Fields("name"),
}
}