// Code generated by ent, DO NOT EDIT.

package preimageshare

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 preimageshare type in the database.
	Label = "preimage_share"
	// 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"
	// FieldPaymentHash holds the string denoting the payment_hash field in the database.
	FieldPaymentHash = "payment_hash"
	// FieldPreimageShare holds the string denoting the preimage_share field in the database.
	FieldPreimageShare = "preimage_share"
	// FieldThreshold holds the string denoting the threshold field in the database.
	FieldThreshold = "threshold"
	// FieldOwnerIdentityPubkey holds the string denoting the owner_identity_pubkey field in the database.
	FieldOwnerIdentityPubkey = "owner_identity_pubkey"
	// FieldInvoiceString holds the string denoting the invoice_string field in the database.
	FieldInvoiceString = "invoice_string"
	// EdgePreimageRequest holds the string denoting the preimage_request edge name in mutations.
	EdgePreimageRequest = "preimage_request"
	// Table holds the table name of the preimageshare in the database.
	Table = "preimage_shares"
	// PreimageRequestTable is the table that holds the preimage_request relation/edge.
	PreimageRequestTable = "preimage_shares"
	// PreimageRequestInverseTable is the table name for the PreimageRequest entity.
	// It exists in this package in order to avoid circular dependency with the "preimagerequest" package.
	PreimageRequestInverseTable = "preimage_requests"
	// PreimageRequestColumn is the table column denoting the preimage_request relation/edge.
	PreimageRequestColumn = "preimage_request_preimage_shares"
)

// Columns holds all SQL columns for preimageshare fields.
var Columns = []string{
	FieldID,
	FieldCreateTime,
	FieldUpdateTime,
	FieldPaymentHash,
	FieldPreimageShare,
	FieldThreshold,
	FieldOwnerIdentityPubkey,
	FieldInvoiceString,
}

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

// 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
	// PaymentHashValidator is a validator for the "payment_hash" field. It is called by the builders before save.
	PaymentHashValidator func([]byte) error
	// PreimageShareValidator is a validator for the "preimage_share" field. It is called by the builders before save.
	PreimageShareValidator func([]byte) error
	// InvoiceStringValidator is a validator for the "invoice_string" field. It is called by the builders before save.
	InvoiceStringValidator 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 PreimageShare 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()
}

// ByThreshold orders the results by the threshold field.
func ByThreshold(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldThreshold, opts...).ToFunc()
}

// ByInvoiceString orders the results by the invoice_string field.
func ByInvoiceString(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldInvoiceString, opts...).ToFunc()
}

// ByPreimageRequestField orders the results by preimage_request field.
func ByPreimageRequestField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPreimageRequestStep(), sql.OrderByField(field, opts...))
	}
}
func newPreimageRequestStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PreimageRequestInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, true, PreimageRequestTable, PreimageRequestColumn),
	)
}
