versia-go/ent/schema/follow.go

36 lines
670 B
Go
Raw Normal View History

2024-08-11 03:51:22 +02:00
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
type Follow struct{ ent.Schema }
func (Follow) Fields() []ent.Field {
return []ent.Field{
2024-08-20 22:43:26 +02:00
field.Enum("status").
Values("pending", "accepted").
Default("pending"),
2024-08-11 03:51:22 +02:00
}
}
func (Follow) Edges() []ent.Edge {
return []ent.Edge{
edge.To("follower", User.Type).Unique().Required(),
edge.To("followee", User.Type).Unique().Required(),
}
}
func (Follow) Indexes() []ent.Index {
return []ent.Index{
index.Edges("follower", "followee").Unique(),
}
}
func (Follow) Mixin() []ent.Mixin {
2024-08-22 23:09:58 +02:00
return []ent.Mixin{VersiaEntityMixin{}}
2024-08-11 03:51:22 +02:00
}