// Code generated by ent, DO NOT EDIT.

package enrollment

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

const (
	// Label holds the string label denoting the enrollment type in the database.
	Label = "enrollment"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldSemester holds the string denoting the semester field in the database.
	FieldSemester = "semester"
	// FieldYear holds the string denoting the year field in the database.
	FieldYear = "year"
	// EdgeStudent holds the string denoting the student edge name in mutations.
	EdgeStudent = "student"
	// EdgeCourse holds the string denoting the course edge name in mutations.
	EdgeCourse = "course"
	// Table holds the table name of the enrollment in the database.
	Table = "enrollments"
	// StudentTable is the table that holds the student relation/edge.
	StudentTable = "enrollments"
	// StudentInverseTable is the table name for the Student entity.
	// It exists in this package in order to avoid circular dependency with the "student" package.
	StudentInverseTable = "students"
	// StudentColumn is the table column denoting the student relation/edge.
	StudentColumn = "student_enrollments"
	// CourseTable is the table that holds the course relation/edge.
	CourseTable = "enrollments"
	// CourseInverseTable is the table name for the Course entity.
	// It exists in this package in order to avoid circular dependency with the "course" package.
	CourseInverseTable = "courses"
	// CourseColumn is the table column denoting the course relation/edge.
	CourseColumn = "course_enrollments"
)

// Columns holds all SQL columns for enrollment fields.
var Columns = []string{
	FieldID,
	FieldSemester,
	FieldYear,
}

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

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

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

// BySemester orders the results by the semester field.
func BySemester(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSemester, opts...).ToFunc()
}

// ByYear orders the results by the year field.
func ByYear(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldYear, opts...).ToFunc()
}

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

// ByCourseField orders the results by course field.
func ByCourseField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newCourseStep(), sql.OrderByField(field, opts...))
	}
}
func newStudentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(StudentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, StudentTable, StudentColumn),
	)
}
func newCourseStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CourseInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, CourseTable, CourseColumn),
	)
}
