// Code generated by ent, DO NOT EDIT.

package payloaddigest

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

const (
	// Label holds the string label denoting the payloaddigest type in the database.
	Label = "payload_digest"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldAlgorithm holds the string denoting the algorithm field in the database.
	FieldAlgorithm = "algorithm"
	// FieldValue holds the string denoting the value field in the database.
	FieldValue = "value"
	// EdgeDsse holds the string denoting the dsse edge name in mutations.
	EdgeDsse = "dsse"
	// Table holds the table name of the payloaddigest in the database.
	Table = "payload_digests"
	// DsseTable is the table that holds the dsse relation/edge.
	DsseTable = "payload_digests"
	// DsseInverseTable is the table name for the Dsse entity.
	// It exists in this package in order to avoid circular dependency with the "dsse" package.
	DsseInverseTable = "dsses"
	// DsseColumn is the table column denoting the dsse relation/edge.
	DsseColumn = "dsse_payload_digests"
)

// Columns holds all SQL columns for payloaddigest fields.
var Columns = []string{
	FieldID,
	FieldAlgorithm,
	FieldValue,
}

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

// 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 (
	// AlgorithmValidator is a validator for the "algorithm" field. It is called by the builders before save.
	AlgorithmValidator func(string) error
	// ValueValidator is a validator for the "value" field. It is called by the builders before save.
	ValueValidator func(string) error
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

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

// ByAlgorithm orders the results by the algorithm field.
func ByAlgorithm(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAlgorithm, opts...).ToFunc()
}

// ByValue orders the results by the value field.
func ByValue(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldValue, opts...).ToFunc()
}

// ByDsseField orders the results by dsse field.
func ByDsseField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newDsseStep(), sql.OrderByField(field, opts...))
	}
}
func newDsseStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(DsseInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, DsseTable, DsseColumn),
	)
}
