174 lines
5.3 KiB
Go
174 lines
5.3 KiB
Go
|
// Code generated by ent, DO NOT EDIT.
|
||
|
|
||
|
package ent
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
"time"
|
||
|
|
||
|
"entgo.io/ent"
|
||
|
"entgo.io/ent/dialect/sql"
|
||
|
"git.dotya.ml/mirre-mt/pcmt/ent/agekey"
|
||
|
"git.dotya.ml/mirre-mt/pcmt/ent/user"
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
// AgeKey is the model entity for the AgeKey schema.
|
||
|
type AgeKey struct {
|
||
|
config `json:"-"`
|
||
|
// ID of the ent.
|
||
|
ID uuid.UUID `json:"id,omitempty"`
|
||
|
// age ed25519 identity stored encrypted using AES256
|
||
|
Key *[]byte `json:"key,omitempty"`
|
||
|
// Created holds the value of the "created" field.
|
||
|
Created time.Time `json:"created,omitempty"`
|
||
|
// Updated holds the value of the "updated" field.
|
||
|
Updated time.Time `json:"updated,omitempty"`
|
||
|
// id of the key owner
|
||
|
Owner uuid.UUID `json:"owner,omitempty"`
|
||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||
|
// The values are being populated by the AgeKeyQuery when eager-loading is set.
|
||
|
Edges AgeKeyEdges `json:"edges"`
|
||
|
selectValues sql.SelectValues
|
||
|
}
|
||
|
|
||
|
// AgeKeyEdges holds the relations/edges for other nodes in the graph.
|
||
|
type AgeKeyEdges struct {
|
||
|
// User holds the value of the user edge.
|
||
|
User *User `json:"user,omitempty"`
|
||
|
// loadedTypes holds the information for reporting if a
|
||
|
// type was loaded (or requested) in eager-loading or not.
|
||
|
loadedTypes [1]bool
|
||
|
}
|
||
|
|
||
|
// UserOrErr returns the User value or an error if the edge
|
||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||
|
func (e AgeKeyEdges) UserOrErr() (*User, error) {
|
||
|
if e.loadedTypes[0] {
|
||
|
if e.User == nil {
|
||
|
// Edge was loaded but was not found.
|
||
|
return nil, &NotFoundError{label: user.Label}
|
||
|
}
|
||
|
return e.User, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "user"}
|
||
|
}
|
||
|
|
||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||
|
func (*AgeKey) scanValues(columns []string) ([]any, error) {
|
||
|
values := make([]any, len(columns))
|
||
|
for i := range columns {
|
||
|
switch columns[i] {
|
||
|
case agekey.FieldKey:
|
||
|
values[i] = new([]byte)
|
||
|
case agekey.FieldCreated, agekey.FieldUpdated:
|
||
|
values[i] = new(sql.NullTime)
|
||
|
case agekey.FieldID, agekey.FieldOwner:
|
||
|
values[i] = new(uuid.UUID)
|
||
|
default:
|
||
|
values[i] = new(sql.UnknownType)
|
||
|
}
|
||
|
}
|
||
|
return values, nil
|
||
|
}
|
||
|
|
||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||
|
// to the AgeKey fields.
|
||
|
func (ak *AgeKey) 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 agekey.FieldID:
|
||
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||
|
} else if value != nil {
|
||
|
ak.ID = *value
|
||
|
}
|
||
|
case agekey.FieldKey:
|
||
|
if value, ok := values[i].(*[]byte); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field key", values[i])
|
||
|
} else if value != nil {
|
||
|
ak.Key = value
|
||
|
}
|
||
|
case agekey.FieldCreated:
|
||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field created", values[i])
|
||
|
} else if value.Valid {
|
||
|
ak.Created = value.Time
|
||
|
}
|
||
|
case agekey.FieldUpdated:
|
||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field updated", values[i])
|
||
|
} else if value.Valid {
|
||
|
ak.Updated = value.Time
|
||
|
}
|
||
|
case agekey.FieldOwner:
|
||
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field owner", values[i])
|
||
|
} else if value != nil {
|
||
|
ak.Owner = *value
|
||
|
}
|
||
|
default:
|
||
|
ak.selectValues.Set(columns[i], values[i])
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Value returns the ent.Value that was dynamically selected and assigned to the AgeKey.
|
||
|
// This includes values selected through modifiers, order, etc.
|
||
|
func (ak *AgeKey) Value(name string) (ent.Value, error) {
|
||
|
return ak.selectValues.Get(name)
|
||
|
}
|
||
|
|
||
|
// QueryUser queries the "user" edge of the AgeKey entity.
|
||
|
func (ak *AgeKey) QueryUser() *UserQuery {
|
||
|
return NewAgeKeyClient(ak.config).QueryUser(ak)
|
||
|
}
|
||
|
|
||
|
// Update returns a builder for updating this AgeKey.
|
||
|
// Note that you need to call AgeKey.Unwrap() before calling this method if this AgeKey
|
||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
|
func (ak *AgeKey) Update() *AgeKeyUpdateOne {
|
||
|
return NewAgeKeyClient(ak.config).UpdateOne(ak)
|
||
|
}
|
||
|
|
||
|
// Unwrap unwraps the AgeKey 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 (ak *AgeKey) Unwrap() *AgeKey {
|
||
|
_tx, ok := ak.config.driver.(*txDriver)
|
||
|
if !ok {
|
||
|
panic("ent: AgeKey is not a transactional entity")
|
||
|
}
|
||
|
ak.config.driver = _tx.drv
|
||
|
return ak
|
||
|
}
|
||
|
|
||
|
// String implements the fmt.Stringer.
|
||
|
func (ak *AgeKey) String() string {
|
||
|
var builder strings.Builder
|
||
|
builder.WriteString("AgeKey(")
|
||
|
builder.WriteString(fmt.Sprintf("id=%v, ", ak.ID))
|
||
|
if v := ak.Key; v != nil {
|
||
|
builder.WriteString("key=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
||
|
}
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("created=")
|
||
|
builder.WriteString(ak.Created.Format(time.ANSIC))
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("updated=")
|
||
|
builder.WriteString(ak.Updated.Format(time.ANSIC))
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("owner=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", ak.Owner))
|
||
|
builder.WriteByte(')')
|
||
|
return builder.String()
|
||
|
}
|
||
|
|
||
|
// AgeKeys is a parsable slice of AgeKey.
|
||
|
type AgeKeys []*AgeKey
|