203 lines
6.7 KiB
Go
203 lines
6.7 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"thesis/ent/transactions"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Transactions is the model entity for the Transactions schema.
|
|
type Transactions struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// Type holds the value of the "type" field.
|
|
Type int `json:"type,omitempty"`
|
|
// Timestamp holds the value of the "timestamp" field.
|
|
Timestamp int `json:"timestamp,omitempty"`
|
|
// Comment holds the value of the "comment" field.
|
|
Comment string `json:"comment,omitempty"`
|
|
// Content holds the value of the "content" field.
|
|
Content []byte `json:"content,omitempty"`
|
|
// Hash holds the value of the "hash" field.
|
|
Hash string `json:"hash,omitempty"`
|
|
// Signature holds the value of the "signature" field.
|
|
Signature string `json:"signature,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the TransactionsQuery when eager-loading is set.
|
|
Edges TransactionsEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// TransactionsEdges holds the relations/edges for other nodes in the graph.
|
|
type TransactionsEdges struct {
|
|
// Signer holds the value of the Signer edge.
|
|
Signer []*Key `json:"Signer,omitempty"`
|
|
// Block holds the value of the Block edge.
|
|
Block []*Blocks `json:"Block,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [2]bool
|
|
}
|
|
|
|
// SignerOrErr returns the Signer value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e TransactionsEdges) SignerOrErr() ([]*Key, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Signer, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "Signer"}
|
|
}
|
|
|
|
// BlockOrErr returns the Block value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e TransactionsEdges) BlockOrErr() ([]*Blocks, error) {
|
|
if e.loadedTypes[1] {
|
|
return e.Block, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "Block"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Transactions) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case transactions.FieldContent:
|
|
values[i] = new([]byte)
|
|
case transactions.FieldID, transactions.FieldType, transactions.FieldTimestamp:
|
|
values[i] = new(sql.NullInt64)
|
|
case transactions.FieldComment, transactions.FieldHash, transactions.FieldSignature:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Transactions fields.
|
|
func (t *Transactions) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case transactions.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
t.ID = int(value.Int64)
|
|
case transactions.FieldType:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field type", values[i])
|
|
} else if value.Valid {
|
|
t.Type = int(value.Int64)
|
|
}
|
|
case transactions.FieldTimestamp:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field timestamp", values[i])
|
|
} else if value.Valid {
|
|
t.Timestamp = int(value.Int64)
|
|
}
|
|
case transactions.FieldComment:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field comment", values[i])
|
|
} else if value.Valid {
|
|
t.Comment = value.String
|
|
}
|
|
case transactions.FieldContent:
|
|
if value, ok := values[i].(*[]byte); !ok {
|
|
return fmt.Errorf("unexpected type %T for field content", values[i])
|
|
} else if value != nil {
|
|
t.Content = *value
|
|
}
|
|
case transactions.FieldHash:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hash", values[i])
|
|
} else if value.Valid {
|
|
t.Hash = value.String
|
|
}
|
|
case transactions.FieldSignature:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field signature", values[i])
|
|
} else if value.Valid {
|
|
t.Signature = value.String
|
|
}
|
|
default:
|
|
t.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Transactions.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (t *Transactions) Value(name string) (ent.Value, error) {
|
|
return t.selectValues.Get(name)
|
|
}
|
|
|
|
// QuerySigner queries the "Signer" edge of the Transactions entity.
|
|
func (t *Transactions) QuerySigner() *KeyQuery {
|
|
return NewTransactionsClient(t.config).QuerySigner(t)
|
|
}
|
|
|
|
// QueryBlock queries the "Block" edge of the Transactions entity.
|
|
func (t *Transactions) QueryBlock() *BlocksQuery {
|
|
return NewTransactionsClient(t.config).QueryBlock(t)
|
|
}
|
|
|
|
// Update returns a builder for updating this Transactions.
|
|
// Note that you need to call Transactions.Unwrap() before calling this method if this Transactions
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (t *Transactions) Update() *TransactionsUpdateOne {
|
|
return NewTransactionsClient(t.config).UpdateOne(t)
|
|
}
|
|
|
|
// Unwrap unwraps the Transactions entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (t *Transactions) Unwrap() *Transactions {
|
|
_tx, ok := t.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Transactions is not a transactional entity")
|
|
}
|
|
t.config.driver = _tx.drv
|
|
return t
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (t *Transactions) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Transactions(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", t.ID))
|
|
builder.WriteString("type=")
|
|
builder.WriteString(fmt.Sprintf("%v", t.Type))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("timestamp=")
|
|
builder.WriteString(fmt.Sprintf("%v", t.Timestamp))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("comment=")
|
|
builder.WriteString(t.Comment)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("content=")
|
|
builder.WriteString(fmt.Sprintf("%v", t.Content))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("hash=")
|
|
builder.WriteString(t.Hash)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("signature=")
|
|
builder.WriteString(t.Signature)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// TransactionsSlice is a parsable slice of Transactions.
|
|
type TransactionsSlice []*Transactions
|