zkt24/z2/backend/ent/key/key.go
2024-04-25 13:51:47 +02:00

120 lines
3.8 KiB
Go

// Code generated by ent, DO NOT EDIT.
package key
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the key type in the database.
Label = "key"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldPublicKey holds the string denoting the publickey field in the database.
FieldPublicKey = "public_key"
// FieldOwner holds the string denoting the owner field in the database.
FieldOwner = "owner"
// FieldTrustScore holds the string denoting the trustscore field in the database.
FieldTrustScore = "trust_score"
// EdgeSigned holds the string denoting the signed edge name in mutations.
EdgeSigned = "Signed"
// Table holds the table name of the key in the database.
Table = "keys"
// SignedTable is the table that holds the Signed relation/edge. The primary key declared below.
SignedTable = "key_Signed"
// SignedInverseTable is the table name for the Transactions entity.
// It exists in this package in order to avoid circular dependency with the "transactions" package.
SignedInverseTable = "transactions"
)
// Columns holds all SQL columns for key fields.
var Columns = []string{
FieldID,
FieldPublicKey,
FieldOwner,
FieldTrustScore,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "keys"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"validators_key",
"white_list_account",
}
var (
// SignedPrimaryKey and SignedColumn2 are the table columns denoting the
// primary key for the Signed relation (M2M).
SignedPrimaryKey = []string{"key_id", "transactions_id"}
)
// 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 (
// PublicKeyValidator is a validator for the "publicKey" field. It is called by the builders before save.
PublicKeyValidator func(string) error
// OwnerValidator is a validator for the "Owner" field. It is called by the builders before save.
OwnerValidator func(string) error
// DefaultTrustScore holds the default value on creation for the "trustScore" field.
DefaultTrustScore float64
)
// OrderOption defines the ordering options for the Key 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()
}
// ByPublicKey orders the results by the publicKey field.
func ByPublicKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPublicKey, opts...).ToFunc()
}
// ByOwner orders the results by the Owner field.
func ByOwner(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOwner, opts...).ToFunc()
}
// ByTrustScore orders the results by the trustScore field.
func ByTrustScore(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTrustScore, opts...).ToFunc()
}
// BySignedCount orders the results by Signed count.
func BySignedCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newSignedStep(), opts...)
}
}
// BySigned orders the results by Signed terms.
func BySigned(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newSignedStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newSignedStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(SignedInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, SignedTable, SignedPrimaryKey...),
)
}