// Code generated by ent, DO NOT EDIT. package post import ( "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the post type in the database. Label = "post" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // FieldSlug holds the string denoting the slug field in the database. FieldSlug = "slug" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // FieldUpdatedAt holds the string denoting the updated_at field in the database. FieldUpdatedAt = "updated_at" // EdgeContents holds the string denoting the contents edge name in mutations. EdgeContents = "contents" // EdgeContributors holds the string denoting the contributors edge name in mutations. EdgeContributors = "contributors" // EdgeCategories holds the string denoting the categories edge name in mutations. EdgeCategories = "categories" // Table holds the table name of the post in the database. Table = "posts" // ContentsTable is the table that holds the contents relation/edge. ContentsTable = "post_contents" // ContentsInverseTable is the table name for the PostContent entity. // It exists in this package in order to avoid circular dependency with the "postcontent" package. ContentsInverseTable = "post_contents" // ContentsColumn is the table column denoting the contents relation/edge. ContentsColumn = "post_contents" // ContributorsTable is the table that holds the contributors relation/edge. ContributorsTable = "post_contributors" // ContributorsInverseTable is the table name for the PostContributor entity. // It exists in this package in order to avoid circular dependency with the "postcontributor" package. ContributorsInverseTable = "post_contributors" // ContributorsColumn is the table column denoting the contributors relation/edge. ContributorsColumn = "post_contributors" // CategoriesTable is the table that holds the categories relation/edge. The primary key declared below. CategoriesTable = "category_posts" // CategoriesInverseTable is the table name for the Category entity. // It exists in this package in order to avoid circular dependency with the "category" package. CategoriesInverseTable = "categories" ) // Columns holds all SQL columns for post fields. var Columns = []string{ FieldID, FieldStatus, FieldSlug, FieldCreatedAt, FieldUpdatedAt, } var ( // CategoriesPrimaryKey and CategoriesColumn2 are the table columns denoting the // primary key for the categories relation (M2M). CategoriesPrimaryKey = []string{"category_id", "post_id"} ) // 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 } } return false } var ( // SlugValidator is a validator for the "slug" field. It is called by the builders before save. SlugValidator func(string) error // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. UpdateDefaultUpdatedAt func() time.Time ) // Status defines the type for the "status" enum field. type Status string // StatusDraft is the default value of the Status enum. const DefaultStatus = StatusDraft // Status values. const ( StatusDraft Status = "draft" StatusPublished Status = "published" StatusArchived Status = "archived" ) func (s Status) String() string { return string(s) } // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. func StatusValidator(s Status) error { switch s { case StatusDraft, StatusPublished, StatusArchived: return nil default: return fmt.Errorf("post: invalid enum value for status field: %q", s) } } // OrderOption defines the ordering options for the Post 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() } // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } // BySlug orders the results by the slug field. func BySlug(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSlug, opts...).ToFunc() } // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } // ByUpdatedAt orders the results by the updated_at field. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() } // ByContentsCount orders the results by contents count. func ByContentsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newContentsStep(), opts...) } } // ByContents orders the results by contents terms. func ByContents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newContentsStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByContributorsCount orders the results by contributors count. func ByContributorsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newContributorsStep(), opts...) } } // ByContributors orders the results by contributors terms. func ByContributors(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newContributorsStep(), append([]sql.OrderTerm{term}, terms...)...) } } // ByCategoriesCount orders the results by categories count. func ByCategoriesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newCategoriesStep(), opts...) } } // ByCategories orders the results by categories terms. func ByCategories(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newCategoriesStep(), append([]sql.OrderTerm{term}, terms...)...) } } func newContentsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ContentsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, ContentsTable, ContentsColumn), ) } func newContributorsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ContributorsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, ContributorsTable, ContributorsColumn), ) } func newCategoriesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(CategoriesInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, true, CategoriesTable, CategoriesPrimaryKey...), ) }