// Code generated by ent, DO NOT EDIT.

package casmapping

import (
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
)

const (
	// Label holds the string label denoting the casmapping type in the database.
	Label = "cas_mapping"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldDigest holds the string denoting the digest field in the database.
	FieldDigest = "digest"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// FieldWorkflowRunID holds the string denoting the workflow_run_id field in the database.
	FieldWorkflowRunID = "workflow_run_id"
	// FieldOrganizationID holds the string denoting the organization_id field in the database.
	FieldOrganizationID = "organization_id"
	// FieldProjectID holds the string denoting the project_id field in the database.
	FieldProjectID = "project_id"
	// EdgeCasBackend holds the string denoting the cas_backend edge name in mutations.
	EdgeCasBackend = "cas_backend"
	// EdgeOrganization holds the string denoting the organization edge name in mutations.
	EdgeOrganization = "organization"
	// EdgeProject holds the string denoting the project edge name in mutations.
	EdgeProject = "project"
	// Table holds the table name of the casmapping in the database.
	Table = "cas_mappings"
	// CasBackendTable is the table that holds the cas_backend relation/edge.
	CasBackendTable = "cas_mappings"
	// CasBackendInverseTable is the table name for the CASBackend entity.
	// It exists in this package in order to avoid circular dependency with the "casbackend" package.
	CasBackendInverseTable = "cas_backends"
	// CasBackendColumn is the table column denoting the cas_backend relation/edge.
	CasBackendColumn = "cas_mapping_cas_backend"
	// OrganizationTable is the table that holds the organization relation/edge.
	OrganizationTable = "cas_mappings"
	// OrganizationInverseTable is the table name for the Organization entity.
	// It exists in this package in order to avoid circular dependency with the "organization" package.
	OrganizationInverseTable = "organizations"
	// OrganizationColumn is the table column denoting the organization relation/edge.
	OrganizationColumn = "organization_id"
	// ProjectTable is the table that holds the project relation/edge.
	ProjectTable = "cas_mappings"
	// ProjectInverseTable is the table name for the Project entity.
	// It exists in this package in order to avoid circular dependency with the "project" package.
	ProjectInverseTable = "projects"
	// ProjectColumn is the table column denoting the project relation/edge.
	ProjectColumn = "project_id"
)

// Columns holds all SQL columns for casmapping fields.
var Columns = []string{
	FieldID,
	FieldDigest,
	FieldCreatedAt,
	FieldWorkflowRunID,
	FieldOrganizationID,
	FieldProjectID,
}

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

// 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 (
	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
	DefaultCreatedAt func() time.Time
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

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

// ByDigest orders the results by the digest field.
func ByDigest(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDigest, opts...).ToFunc()
}

// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

// ByWorkflowRunID orders the results by the workflow_run_id field.
func ByWorkflowRunID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWorkflowRunID, opts...).ToFunc()
}

// ByOrganizationID orders the results by the organization_id field.
func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
}

// ByProjectID orders the results by the project_id field.
func ByProjectID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldProjectID, opts...).ToFunc()
}

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

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

// ByProjectField orders the results by project field.
func ByProjectField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newProjectStep(), sql.OrderByField(field, opts...))
	}
}
func newCasBackendStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CasBackendInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, CasBackendTable, CasBackendColumn),
	)
}
func newOrganizationStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(OrganizationInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, OrganizationTable, OrganizationColumn),
	)
}
func newProjectStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(ProjectInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, ProjectTable, ProjectColumn),
	)
}
