// Code generated by ent, DO NOT EDIT.

package article

import (
	"fmt"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the article type in the database.
	Label = "article"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
	FieldDeletedAt = "deleted_at"
	// 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"
	// FieldTitle holds the string denoting the title field in the database.
	FieldTitle = "title"
	// FieldContentMd holds the string denoting the content_md field in the database.
	FieldContentMd = "content_md"
	// FieldContentHTML holds the string denoting the content_html field in the database.
	FieldContentHTML = "content_html"
	// FieldCoverURL holds the string denoting the cover_url field in the database.
	FieldCoverURL = "cover_url"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldViewCount holds the string denoting the view_count field in the database.
	FieldViewCount = "view_count"
	// FieldWordCount holds the string denoting the word_count field in the database.
	FieldWordCount = "word_count"
	// FieldReadingTime holds the string denoting the reading_time field in the database.
	FieldReadingTime = "reading_time"
	// FieldIPLocation holds the string denoting the ip_location field in the database.
	FieldIPLocation = "ip_location"
	// FieldPrimaryColor holds the string denoting the primary_color field in the database.
	FieldPrimaryColor = "primary_color"
	// FieldIsPrimaryColorManual holds the string denoting the is_primary_color_manual field in the database.
	FieldIsPrimaryColorManual = "is_primary_color_manual"
	// FieldHomeSort holds the string denoting the home_sort field in the database.
	FieldHomeSort = "home_sort"
	// FieldPinSort holds the string denoting the pin_sort field in the database.
	FieldPinSort = "pin_sort"
	// FieldTopImgURL holds the string denoting the top_img_url field in the database.
	FieldTopImgURL = "top_img_url"
	// FieldSummaries holds the string denoting the summaries field in the database.
	FieldSummaries = "summaries"
	// FieldAbbrlink holds the string denoting the abbrlink field in the database.
	FieldAbbrlink = "abbrlink"
	// FieldCopyright holds the string denoting the copyright field in the database.
	FieldCopyright = "copyright"
	// FieldCopyrightAuthor holds the string denoting the copyright_author field in the database.
	FieldCopyrightAuthor = "copyright_author"
	// FieldCopyrightAuthorHref holds the string denoting the copyright_author_href field in the database.
	FieldCopyrightAuthorHref = "copyright_author_href"
	// FieldCopyrightURL holds the string denoting the copyright_url field in the database.
	FieldCopyrightURL = "copyright_url"
	// EdgePostTags holds the string denoting the post_tags edge name in mutations.
	EdgePostTags = "post_tags"
	// EdgePostCategories holds the string denoting the post_categories edge name in mutations.
	EdgePostCategories = "post_categories"
	// EdgeComments holds the string denoting the comments edge name in mutations.
	EdgeComments = "comments"
	// Table holds the table name of the article in the database.
	Table = "articles"
	// PostTagsTable is the table that holds the post_tags relation/edge. The primary key declared below.
	PostTagsTable = "article_post_tags"
	// PostTagsInverseTable is the table name for the PostTag entity.
	// It exists in this package in order to avoid circular dependency with the "posttag" package.
	PostTagsInverseTable = "post_tags"
	// PostCategoriesTable is the table that holds the post_categories relation/edge. The primary key declared below.
	PostCategoriesTable = "article_post_categories"
	// PostCategoriesInverseTable is the table name for the PostCategory entity.
	// It exists in this package in order to avoid circular dependency with the "postcategory" package.
	PostCategoriesInverseTable = "post_categories"
	// CommentsTable is the table that holds the comments relation/edge.
	CommentsTable = "comments"
	// CommentsInverseTable is the table name for the Comment entity.
	// It exists in this package in order to avoid circular dependency with the "comment" package.
	CommentsInverseTable = "comments"
	// CommentsColumn is the table column denoting the comments relation/edge.
	CommentsColumn = "article_comments"
)

// Columns holds all SQL columns for article fields.
var Columns = []string{
	FieldID,
	FieldDeletedAt,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldTitle,
	FieldContentMd,
	FieldContentHTML,
	FieldCoverURL,
	FieldStatus,
	FieldViewCount,
	FieldWordCount,
	FieldReadingTime,
	FieldIPLocation,
	FieldPrimaryColor,
	FieldIsPrimaryColorManual,
	FieldHomeSort,
	FieldPinSort,
	FieldTopImgURL,
	FieldSummaries,
	FieldAbbrlink,
	FieldCopyright,
	FieldCopyrightAuthor,
	FieldCopyrightAuthorHref,
	FieldCopyrightURL,
}

var (
	// PostTagsPrimaryKey and PostTagsColumn2 are the table columns denoting the
	// primary key for the post_tags relation (M2M).
	PostTagsPrimaryKey = []string{"article_id", "post_tag_id"}
	// PostCategoriesPrimaryKey and PostCategoriesColumn2 are the table columns denoting the
	// primary key for the post_categories relation (M2M).
	PostCategoriesPrimaryKey = []string{"article_id", "post_category_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
}

// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
//	import _ "github.com/anzhiyu-c/anheyu-app/ent/runtime"
var (
	Hooks [1]ent.Hook
	// 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
	// TitleValidator is a validator for the "title" field. It is called by the builders before save.
	TitleValidator func(string) error
	// DefaultViewCount holds the default value on creation for the "view_count" field.
	DefaultViewCount int
	// ViewCountValidator is a validator for the "view_count" field. It is called by the builders before save.
	ViewCountValidator func(int) error
	// DefaultWordCount holds the default value on creation for the "word_count" field.
	DefaultWordCount int
	// WordCountValidator is a validator for the "word_count" field. It is called by the builders before save.
	WordCountValidator func(int) error
	// DefaultReadingTime holds the default value on creation for the "reading_time" field.
	DefaultReadingTime int
	// ReadingTimeValidator is a validator for the "reading_time" field. It is called by the builders before save.
	ReadingTimeValidator func(int) error
	// DefaultPrimaryColor holds the default value on creation for the "primary_color" field.
	DefaultPrimaryColor string
	// DefaultIsPrimaryColorManual holds the default value on creation for the "is_primary_color_manual" field.
	DefaultIsPrimaryColorManual bool
	// DefaultHomeSort holds the default value on creation for the "home_sort" field.
	DefaultHomeSort int
	// HomeSortValidator is a validator for the "home_sort" field. It is called by the builders before save.
	HomeSortValidator func(int) error
	// DefaultPinSort holds the default value on creation for the "pin_sort" field.
	DefaultPinSort int
	// PinSortValidator is a validator for the "pin_sort" field. It is called by the builders before save.
	PinSortValidator func(int) error
	// DefaultCopyright holds the default value on creation for the "copyright" field.
	DefaultCopyright bool
)

// 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("article: invalid enum value for status field: %q", s)
	}
}

// OrderOption defines the ordering options for the Article 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()
}

// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDeletedAt, 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()
}

// ByTitle orders the results by the title field.
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTitle, opts...).ToFunc()
}

// ByContentMd orders the results by the content_md field.
func ByContentMd(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContentMd, opts...).ToFunc()
}

// ByContentHTML orders the results by the content_html field.
func ByContentHTML(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContentHTML, opts...).ToFunc()
}

// ByCoverURL orders the results by the cover_url field.
func ByCoverURL(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCoverURL, opts...).ToFunc()
}

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByViewCount orders the results by the view_count field.
func ByViewCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldViewCount, opts...).ToFunc()
}

// ByWordCount orders the results by the word_count field.
func ByWordCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWordCount, opts...).ToFunc()
}

// ByReadingTime orders the results by the reading_time field.
func ByReadingTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldReadingTime, opts...).ToFunc()
}

// ByIPLocation orders the results by the ip_location field.
func ByIPLocation(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldIPLocation, opts...).ToFunc()
}

// ByPrimaryColor orders the results by the primary_color field.
func ByPrimaryColor(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPrimaryColor, opts...).ToFunc()
}

// ByIsPrimaryColorManual orders the results by the is_primary_color_manual field.
func ByIsPrimaryColorManual(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldIsPrimaryColorManual, opts...).ToFunc()
}

// ByHomeSort orders the results by the home_sort field.
func ByHomeSort(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldHomeSort, opts...).ToFunc()
}

// ByPinSort orders the results by the pin_sort field.
func ByPinSort(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPinSort, opts...).ToFunc()
}

// ByTopImgURL orders the results by the top_img_url field.
func ByTopImgURL(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTopImgURL, opts...).ToFunc()
}

// ByAbbrlink orders the results by the abbrlink field.
func ByAbbrlink(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAbbrlink, opts...).ToFunc()
}

// ByCopyright orders the results by the copyright field.
func ByCopyright(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCopyright, opts...).ToFunc()
}

// ByCopyrightAuthor orders the results by the copyright_author field.
func ByCopyrightAuthor(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCopyrightAuthor, opts...).ToFunc()
}

// ByCopyrightAuthorHref orders the results by the copyright_author_href field.
func ByCopyrightAuthorHref(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCopyrightAuthorHref, opts...).ToFunc()
}

// ByCopyrightURL orders the results by the copyright_url field.
func ByCopyrightURL(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCopyrightURL, opts...).ToFunc()
}

// ByPostTagsCount orders the results by post_tags count.
func ByPostTagsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPostTagsStep(), opts...)
	}
}

// ByPostTags orders the results by post_tags terms.
func ByPostTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPostTagsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByPostCategoriesCount orders the results by post_categories count.
func ByPostCategoriesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPostCategoriesStep(), opts...)
	}
}

// ByPostCategories orders the results by post_categories terms.
func ByPostCategories(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPostCategoriesStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByCommentsCount orders the results by comments count.
func ByCommentsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newCommentsStep(), opts...)
	}
}

// ByComments orders the results by comments terms.
func ByComments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newCommentsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newPostTagsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PostTagsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, false, PostTagsTable, PostTagsPrimaryKey...),
	)
}
func newPostCategoriesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PostCategoriesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, false, PostCategoriesTable, PostCategoriesPrimaryKey...),
	)
}
func newCommentsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CommentsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, CommentsTable, CommentsColumn),
	)
}
