// Code generated by ent, DO NOT EDIT.

package transferleaf

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 transferleaf type in the database.
	Label = "transfer_leaf"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreateTime holds the string denoting the create_time field in the database.
	FieldCreateTime = "create_time"
	// FieldUpdateTime holds the string denoting the update_time field in the database.
	FieldUpdateTime = "update_time"
	// FieldSecretCipher holds the string denoting the secret_cipher field in the database.
	FieldSecretCipher = "secret_cipher"
	// FieldSignature holds the string denoting the signature field in the database.
	FieldSignature = "signature"
	// FieldPreviousRefundTx holds the string denoting the previous_refund_tx field in the database.
	FieldPreviousRefundTx = "previous_refund_tx"
	// FieldPreviousDirectRefundTx holds the string denoting the previous_direct_refund_tx field in the database.
	FieldPreviousDirectRefundTx = "previous_direct_refund_tx"
	// FieldPreviousDirectFromCpfpRefundTx holds the string denoting the previous_direct_from_cpfp_refund_tx field in the database.
	FieldPreviousDirectFromCpfpRefundTx = "previous_direct_from_cpfp_refund_tx"
	// FieldIntermediateRefundTx holds the string denoting the intermediate_refund_tx field in the database.
	FieldIntermediateRefundTx = "intermediate_refund_tx"
	// FieldIntermediateDirectRefundTx holds the string denoting the intermediate_direct_refund_tx field in the database.
	FieldIntermediateDirectRefundTx = "intermediate_direct_refund_tx"
	// FieldIntermediateDirectFromCpfpRefundTx holds the string denoting the intermediate_direct_from_cpfp_refund_tx field in the database.
	FieldIntermediateDirectFromCpfpRefundTx = "intermediate_direct_from_cpfp_refund_tx"
	// FieldKeyTweak holds the string denoting the key_tweak field in the database.
	FieldKeyTweak = "key_tweak"
	// FieldSenderKeyTweakProof holds the string denoting the sender_key_tweak_proof field in the database.
	FieldSenderKeyTweakProof = "sender_key_tweak_proof"
	// FieldReceiverKeyTweak holds the string denoting the receiver_key_tweak field in the database.
	FieldReceiverKeyTweak = "receiver_key_tweak"
	// EdgeTransfer holds the string denoting the transfer edge name in mutations.
	EdgeTransfer = "transfer"
	// EdgeLeaf holds the string denoting the leaf edge name in mutations.
	EdgeLeaf = "leaf"
	// Table holds the table name of the transferleaf in the database.
	Table = "transfer_leafs"
	// TransferTable is the table that holds the transfer relation/edge.
	TransferTable = "transfer_leafs"
	// TransferInverseTable is the table name for the Transfer entity.
	// It exists in this package in order to avoid circular dependency with the "transfer" package.
	TransferInverseTable = "transfers"
	// TransferColumn is the table column denoting the transfer relation/edge.
	TransferColumn = "transfer_leaf_transfer"
	// LeafTable is the table that holds the leaf relation/edge.
	LeafTable = "transfer_leafs"
	// LeafInverseTable is the table name for the TreeNode entity.
	// It exists in this package in order to avoid circular dependency with the "treenode" package.
	LeafInverseTable = "tree_nodes"
	// LeafColumn is the table column denoting the leaf relation/edge.
	LeafColumn = "transfer_leaf_leaf"
)

// Columns holds all SQL columns for transferleaf fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldSecretCipher,
	FieldSignature,
	FieldPreviousRefundTx,
	FieldPreviousDirectRefundTx,
	FieldPreviousDirectFromCpfpRefundTx,
	FieldIntermediateRefundTx,
	FieldIntermediateDirectRefundTx,
	FieldIntermediateDirectFromCpfpRefundTx,
	FieldKeyTweak,
	FieldSenderKeyTweakProof,
	FieldReceiverKeyTweak,
}

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

// 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 (
	// DefaultCreateTime holds the default value on creation for the "create_time" field.
	DefaultCreateTime func() time.Time
	// DefaultUpdateTime holds the default value on creation for the "update_time" field.
	DefaultUpdateTime func() time.Time
	// UpdateDefaultUpdateTime holds the default value on update for the "update_time" field.
	UpdateDefaultUpdateTime func() time.Time
	// PreviousRefundTxValidator is a validator for the "previous_refund_tx" field. It is called by the builders before save.
	PreviousRefundTxValidator func([]byte) error
	// IntermediateRefundTxValidator is a validator for the "intermediate_refund_tx" field. It is called by the builders before save.
	IntermediateRefundTxValidator func([]byte) error
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

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

// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}

// ByUpdateTime orders the results by the update_time field.
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
}

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

// ByLeafField orders the results by leaf field.
func ByLeafField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newLeafStep(), sql.OrderByField(field, opts...))
	}
}
func newTransferStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TransferInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, TransferTable, TransferColumn),
	)
}
func newLeafStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(LeafInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, LeafTable, LeafColumn),
	)
}
