// Code generated by ent, DO NOT EDIT.

package course

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

const (
	// Label holds the string label denoting the course type in the database.
	Label = "course"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldTitle holds the string denoting the title field in the database.
	FieldTitle = "title"
	// EdgeDepartment holds the string denoting the department edge name in mutations.
	EdgeDepartment = "department"
	// EdgeEnrollments holds the string denoting the enrollments edge name in mutations.
	EdgeEnrollments = "enrollments"
	// Table holds the table name of the course in the database.
	Table = "courses"
	// DepartmentTable is the table that holds the department relation/edge.
	DepartmentTable = "courses"
	// DepartmentInverseTable is the table name for the Department entity.
	// It exists in this package in order to avoid circular dependency with the "department" package.
	DepartmentInverseTable = "departments"
	// DepartmentColumn is the table column denoting the department relation/edge.
	DepartmentColumn = "department_courses"
	// EnrollmentsTable is the table that holds the enrollments relation/edge.
	EnrollmentsTable = "enrollments"
	// EnrollmentsInverseTable is the table name for the Enrollment entity.
	// It exists in this package in order to avoid circular dependency with the "enrollment" package.
	EnrollmentsInverseTable = "enrollments"
	// EnrollmentsColumn is the table column denoting the enrollments relation/edge.
	EnrollmentsColumn = "course_enrollments"
)

// Columns holds all SQL columns for course fields.
var Columns = []string{
	FieldID,
	FieldTitle,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "courses"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"department_courses",
}

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

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

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

// ByDepartmentField orders the results by department field.
func ByDepartmentField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newDepartmentStep(), sql.OrderByField(field, opts...))
	}
}

// ByEnrollmentsCount orders the results by enrollments count.
func ByEnrollmentsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newEnrollmentsStep(), opts...)
	}
}

// ByEnrollments orders the results by enrollments terms.
func ByEnrollments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newEnrollmentsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newDepartmentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(DepartmentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, DepartmentTable, DepartmentColumn),
	)
}
func newEnrollmentsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(EnrollmentsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, EnrollmentsTable, EnrollmentsColumn),
	)
}
