// Code generated by ent, DO NOT EDIT. package postcontributor import ( "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the postcontributor type in the database. Label = "post_contributor" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldLanguageCode holds the string denoting the language_code field in the database. FieldLanguageCode = "language_code" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // EdgePost holds the string denoting the post edge name in mutations. EdgePost = "post" // EdgeContributor holds the string denoting the contributor edge name in mutations. EdgeContributor = "contributor" // EdgeRole holds the string denoting the role edge name in mutations. EdgeRole = "role" // Table holds the table name of the postcontributor in the database. Table = "post_contributors" // PostTable is the table that holds the post relation/edge. PostTable = "post_contributors" // PostInverseTable is the table name for the Post entity. // It exists in this package in order to avoid circular dependency with the "post" package. PostInverseTable = "posts" // PostColumn is the table column denoting the post relation/edge. PostColumn = "post_contributors" // ContributorTable is the table that holds the contributor relation/edge. ContributorTable = "post_contributors" // ContributorInverseTable is the table name for the Contributor entity. // It exists in this package in order to avoid circular dependency with the "contributor" package. ContributorInverseTable = "contributors" // ContributorColumn is the table column denoting the contributor relation/edge. ContributorColumn = "contributor_posts" // RoleTable is the table that holds the role relation/edge. RoleTable = "post_contributors" // RoleInverseTable is the table name for the ContributorRole entity. // It exists in this package in order to avoid circular dependency with the "contributorrole" package. RoleInverseTable = "contributor_roles" // RoleColumn is the table column denoting the role relation/edge. RoleColumn = "contributor_role_post_contributors" ) // Columns holds all SQL columns for postcontributor fields. var Columns = []string{ FieldID, FieldLanguageCode, FieldCreatedAt, } // ForeignKeys holds the SQL foreign-keys that are owned by the "post_contributors" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "contributor_posts", "contributor_role_post_contributors", "post_contributors", } // ValidColumn reports if the column name is valid (part of the table columns). func ValidColumn(column string) bool { for i := range Columns { if column == Columns[i] { return true } } for i := range ForeignKeys { if column == ForeignKeys[i] { return true } } return false } var ( // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time ) // LanguageCode defines the type for the "language_code" enum field. type LanguageCode string // LanguageCode values. const ( LanguageCodeEn LanguageCode = "en" LanguageCodeZhHans LanguageCode = "zh-Hans" LanguageCodeZhHant LanguageCode = "zh-Hant" ) func (lc LanguageCode) String() string { return string(lc) } // LanguageCodeValidator is a validator for the "language_code" field enum values. It is called by the builders before save. func LanguageCodeValidator(lc LanguageCode) error { switch lc { case LanguageCodeEn, LanguageCodeZhHans, LanguageCodeZhHant: return nil default: return fmt.Errorf("postcontributor: invalid enum value for language_code field: %q", lc) } } // OrderOption defines the ordering options for the PostContributor queries. type OrderOption func(*sql.Selector) // ByID orders the results by the id field. func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } // ByLanguageCode orders the results by the language_code field. func ByLanguageCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLanguageCode, opts...).ToFunc() } // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } // ByPostField orders the results by post field. func ByPostField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newPostStep(), sql.OrderByField(field, opts...)) } } // ByContributorField orders the results by contributor field. func ByContributorField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newContributorStep(), sql.OrderByField(field, opts...)) } } // ByRoleField orders the results by role field. func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) } } func newPostStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PostInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, PostTable, PostColumn), ) } func newContributorStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ContributorInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, ContributorTable, ContributorColumn), ) } func newRoleStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(RoleInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, RoleTable, RoleColumn), ) }