// Code generated by ent, DO NOT EDIT.

package department

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

const (
	// Label holds the string label denoting the department type in the database.
	Label = "department"
	// 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"
	// EdgeInstructors holds the string denoting the instructors edge name in mutations.
	EdgeInstructors = "instructors"
	// EdgeCourses holds the string denoting the courses edge name in mutations.
	EdgeCourses = "courses"
	// EdgeStudents holds the string denoting the students edge name in mutations.
	EdgeStudents = "students"
	// Table holds the table name of the department in the database.
	Table = "departments"
	// InstructorsTable is the table that holds the instructors relation/edge.
	InstructorsTable = "instructors"
	// InstructorsInverseTable is the table name for the Instructor entity.
	// It exists in this package in order to avoid circular dependency with the "instructor" package.
	InstructorsInverseTable = "instructors"
	// InstructorsColumn is the table column denoting the instructors relation/edge.
	InstructorsColumn = "department_instructors"
	// CoursesTable is the table that holds the courses relation/edge.
	CoursesTable = "courses"
	// CoursesInverseTable is the table name for the Course entity.
	// It exists in this package in order to avoid circular dependency with the "course" package.
	CoursesInverseTable = "courses"
	// CoursesColumn is the table column denoting the courses relation/edge.
	CoursesColumn = "department_courses"
	// StudentsTable is the table that holds the students relation/edge.
	StudentsTable = "students"
	// StudentsInverseTable is the table name for the Student entity.
	// It exists in this package in order to avoid circular dependency with the "student" package.
	StudentsInverseTable = "students"
	// StudentsColumn is the table column denoting the students relation/edge.
	StudentsColumn = "department_students"
)

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

// 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
)

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

// ByInstructorsCount orders the results by instructors count.
func ByInstructorsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newInstructorsStep(), opts...)
	}
}

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

// ByCoursesCount orders the results by courses count.
func ByCoursesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newCoursesStep(), opts...)
	}
}

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

// ByStudentsCount orders the results by students count.
func ByStudentsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newStudentsStep(), opts...)
	}
}

// ByStudents orders the results by students terms.
func ByStudents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newStudentsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newInstructorsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(InstructorsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, InstructorsTable, InstructorsColumn),
	)
}
func newCoursesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CoursesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, CoursesTable, CoursesColumn),
	)
}
func newStudentsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(StudentsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, StudentsTable, StudentsColumn),
	)
}
