// Code generated by ent, DO NOT EDIT.

package linkcategory

import (
	"fmt"

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

const (
	// Label holds the string label denoting the linkcategory type in the database.
	Label = "link_category"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldName holds the string denoting the name field in the database.
	FieldName = "name"
	// FieldDescription holds the string denoting the description field in the database.
	FieldDescription = "description"
	// FieldStyle holds the string denoting the style field in the database.
	FieldStyle = "style"
	// EdgeLinks holds the string denoting the links edge name in mutations.
	EdgeLinks = "links"
	// Table holds the table name of the linkcategory in the database.
	Table = "link_categories"
	// LinksTable is the table that holds the links relation/edge.
	LinksTable = "links"
	// LinksInverseTable is the table name for the Link entity.
	// It exists in this package in order to avoid circular dependency with the "link" package.
	LinksInverseTable = "links"
	// LinksColumn is the table column denoting the links relation/edge.
	LinksColumn = "link_category_links"
)

// Columns holds all SQL columns for linkcategory fields.
var Columns = []string{
	FieldID,
	FieldName,
	FieldDescription,
	FieldStyle,
}

// 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 (
	// NameValidator is a validator for the "name" field. It is called by the builders before save.
	NameValidator func(string) error
)

// Style defines the type for the "style" enum field.
type Style string

// StyleCard is the default value of the Style enum.
const DefaultStyle = StyleCard

// Style values.
const (
	StyleCard Style = "card"
	StyleList Style = "list"
)

func (s Style) String() string {
	return string(s)
}

// StyleValidator is a validator for the "style" field enum values. It is called by the builders before save.
func StyleValidator(s Style) error {
	switch s {
	case StyleCard, StyleList:
		return nil
	default:
		return fmt.Errorf("linkcategory: invalid enum value for style field: %q", s)
	}
}

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

// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldName, opts...).ToFunc()
}

// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDescription, opts...).ToFunc()
}

// ByStyle orders the results by the style field.
func ByStyle(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStyle, opts...).ToFunc()
}

// ByLinksCount orders the results by links count.
func ByLinksCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newLinksStep(), opts...)
	}
}

// ByLinks orders the results by links terms.
func ByLinks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newLinksStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newLinksStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(LinksInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, LinksTable, LinksColumn),
	)
}
