package schema import ( "entgo.io/ent" "entgo.io/ent/schema/field" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" "time" ) // PostContributor holds the schema definition for the PostContributor entity. type PostContributor struct { ent.Schema } // Fields of the PostContributor. func (PostContributor) Fields() []ent.Field { return []ent.Field{ field.Enum("language_code"). Values("en", "zh-Hans", "zh-Hant"). Optional(). Nillable(), field.Time("created_at"). Default(time.Now), } } // Edges of the PostContributor. func (PostContributor) Edges() []ent.Edge { return []ent.Edge{ edge.From("post", Post.Type). Ref("contributors"). Unique(), edge.From("contributor", Contributor.Type). Ref("posts"). Unique(), edge.From("role", ContributorRole.Type). Ref("post_contributors"). Unique(), } } // Indexes of the PostContributor. func (PostContributor) Indexes() []ent.Index { return []ent.Index{ index.Fields("language_code"). Edges("post", "contributor", "role"). Unique(), } }