// Code generated by ent, DO NOT EDIT.

package dsse

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 dsse type in the database.
	Label = "dsse"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// FieldGitoidSha256 holds the string denoting the gitoid_sha256 field in the database.
	FieldGitoidSha256 = "gitoid_sha256"
	// FieldPayloadType holds the string denoting the payload_type field in the database.
	FieldPayloadType = "payload_type"
	// EdgeStatement holds the string denoting the statement edge name in mutations.
	EdgeStatement = "statement"
	// EdgeSignatures holds the string denoting the signatures edge name in mutations.
	EdgeSignatures = "signatures"
	// EdgePayloadDigests holds the string denoting the payload_digests edge name in mutations.
	EdgePayloadDigests = "payload_digests"
	// Table holds the table name of the dsse in the database.
	Table = "dsses"
	// StatementTable is the table that holds the statement relation/edge.
	StatementTable = "dsses"
	// StatementInverseTable is the table name for the Statement entity.
	// It exists in this package in order to avoid circular dependency with the "statement" package.
	StatementInverseTable = "statements"
	// StatementColumn is the table column denoting the statement relation/edge.
	StatementColumn = "dsse_statement"
	// SignaturesTable is the table that holds the signatures relation/edge.
	SignaturesTable = "signatures"
	// SignaturesInverseTable is the table name for the Signature entity.
	// It exists in this package in order to avoid circular dependency with the "signature" package.
	SignaturesInverseTable = "signatures"
	// SignaturesColumn is the table column denoting the signatures relation/edge.
	SignaturesColumn = "dsse_signatures"
	// PayloadDigestsTable is the table that holds the payload_digests relation/edge.
	PayloadDigestsTable = "payload_digests"
	// PayloadDigestsInverseTable is the table name for the PayloadDigest entity.
	// It exists in this package in order to avoid circular dependency with the "payloaddigest" package.
	PayloadDigestsInverseTable = "payload_digests"
	// PayloadDigestsColumn is the table column denoting the payload_digests relation/edge.
	PayloadDigestsColumn = "dsse_payload_digests"
)

// Columns holds all SQL columns for dsse fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldGitoidSha256,
	FieldPayloadType,
}

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

// 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
	// GitoidSha256Validator is a validator for the "gitoid_sha256" field. It is called by the builders before save.
	GitoidSha256Validator func(string) error
	// PayloadTypeValidator is a validator for the "payload_type" field. It is called by the builders before save.
	PayloadTypeValidator 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 Dsse 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()
}

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

// ByGitoidSha256 orders the results by the gitoid_sha256 field.
func ByGitoidSha256(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldGitoidSha256, opts...).ToFunc()
}

// ByPayloadType orders the results by the payload_type field.
func ByPayloadType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPayloadType, opts...).ToFunc()
}

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

// BySignaturesCount orders the results by signatures count.
func BySignaturesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newSignaturesStep(), opts...)
	}
}

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

// ByPayloadDigestsCount orders the results by payload_digests count.
func ByPayloadDigestsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPayloadDigestsStep(), opts...)
	}
}

// ByPayloadDigests orders the results by payload_digests terms.
func ByPayloadDigests(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPayloadDigestsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newStatementStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(StatementInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, StatementTable, StatementColumn),
	)
}
func newSignaturesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SignaturesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, SignaturesTable, SignaturesColumn),
	)
}
func newPayloadDigestsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PayloadDigestsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, PayloadDigestsTable, PayloadDigestsColumn),
	)
}
