// Code generated by ent, DO NOT EDIT.

package signature

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

const (
	// Label holds the string label denoting the signature type in the database.
	Label = "signature"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldKeyID holds the string denoting the key_id field in the database.
	FieldKeyID = "key_id"
	// FieldSignature holds the string denoting the signature field in the database.
	FieldSignature = "signature"
	// EdgeDsse holds the string denoting the dsse edge name in mutations.
	EdgeDsse = "dsse"
	// EdgeTimestamps holds the string denoting the timestamps edge name in mutations.
	EdgeTimestamps = "timestamps"
	// Table holds the table name of the signature in the database.
	Table = "signatures"
	// DsseTable is the table that holds the dsse relation/edge.
	DsseTable = "signatures"
	// 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_signatures"
	// TimestampsTable is the table that holds the timestamps relation/edge.
	TimestampsTable = "timestamps"
	// TimestampsInverseTable is the table name for the Timestamp entity.
	// It exists in this package in order to avoid circular dependency with the "timestamp" package.
	TimestampsInverseTable = "timestamps"
	// TimestampsColumn is the table column denoting the timestamps relation/edge.
	TimestampsColumn = "signature_timestamps"
)

// Columns holds all SQL columns for signature fields.
var Columns = []string{
	FieldID,
	FieldKeyID,
	FieldSignature,
}

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

// 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 (
	// SignatureValidator is a validator for the "signature" field. It is called by the builders before save.
	SignatureValidator 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 Signature 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()
}

// ByKeyID orders the results by the key_id field.
func ByKeyID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldKeyID, opts...).ToFunc()
}

// BySignature orders the results by the signature field.
func BySignature(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSignature, 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...))
	}
}

// ByTimestampsCount orders the results by timestamps count.
func ByTimestampsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newTimestampsStep(), opts...)
	}
}

// ByTimestamps orders the results by timestamps terms.
func ByTimestamps(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTimestampsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newDsseStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(DsseInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, DsseTable, DsseColumn),
	)
}
func newTimestampsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TimestampsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, TimestampsTable, TimestampsColumn),
	)
}
