mirror of
https://github.com/versia-pub/versia-go.git
synced 2025-12-06 06:28:18 +01:00
34 lines
662 B
Go
34 lines
662 B
Go
|
|
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{
|
||
|
|
field.Enum("status").Values("pending", "accepted").Default("pending"),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
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 {
|
||
|
|
return []ent.Mixin{LysandEntityMixin{}}
|
||
|
|
}
|