rano/db/ent/verifytoken.go

179 lines
5.9 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"gitserver.in/patialtech/rano/db/ent/user"
"gitserver.in/patialtech/rano/db/ent/verifytoken"
)
// VerifyToken is the model entity for the VerifyToken schema.
type VerifyToken struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"createdAt"`
// ExpiresAt holds the value of the "expires_at" field.
ExpiresAt time.Time `json:"expires_at,omitempty"`
// Token holds the value of the "token" field.
Token string `json:"token,omitempty"`
// Purpose holds the value of the "purpose" field.
Purpose string `json:"purpose,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the VerifyTokenQuery when eager-loading is set.
Edges VerifyTokenEdges `json:"edges"`
user_id *int64
selectValues sql.SelectValues
}
// VerifyTokenEdges holds the relations/edges for other nodes in the graph.
type VerifyTokenEdges 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 VerifyTokenEdges) UserOrErr() (*User, error) {
if e.User != nil {
return e.User, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "user"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*VerifyToken) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case verifytoken.FieldID:
values[i] = new(sql.NullInt64)
case verifytoken.FieldToken, verifytoken.FieldPurpose:
values[i] = new(sql.NullString)
case verifytoken.FieldCreatedAt, verifytoken.FieldExpiresAt:
values[i] = new(sql.NullTime)
case verifytoken.ForeignKeys[0]: // user_id
values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the VerifyToken fields.
func (vt *VerifyToken) 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 verifytoken.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
vt.ID = int64(value.Int64)
case verifytoken.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
vt.CreatedAt = value.Time
}
case verifytoken.FieldExpiresAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field expires_at", values[i])
} else if value.Valid {
vt.ExpiresAt = value.Time
}
case verifytoken.FieldToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i])
} else if value.Valid {
vt.Token = value.String
}
case verifytoken.FieldPurpose:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field purpose", values[i])
} else if value.Valid {
vt.Purpose = value.String
}
case verifytoken.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field user_id", value)
} else if value.Valid {
vt.user_id = new(int64)
*vt.user_id = int64(value.Int64)
}
default:
vt.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the VerifyToken.
// This includes values selected through modifiers, order, etc.
func (vt *VerifyToken) Value(name string) (ent.Value, error) {
return vt.selectValues.Get(name)
}
// QueryUser queries the "user" edge of the VerifyToken entity.
func (vt *VerifyToken) QueryUser() *UserQuery {
return NewVerifyTokenClient(vt.config).QueryUser(vt)
}
// Update returns a builder for updating this VerifyToken.
// Note that you need to call VerifyToken.Unwrap() before calling this method if this VerifyToken
// was returned from a transaction, and the transaction was committed or rolled back.
func (vt *VerifyToken) Update() *VerifyTokenUpdateOne {
return NewVerifyTokenClient(vt.config).UpdateOne(vt)
}
// Unwrap unwraps the VerifyToken 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 (vt *VerifyToken) Unwrap() *VerifyToken {
_tx, ok := vt.config.driver.(*txDriver)
if !ok {
panic("ent: VerifyToken is not a transactional entity")
}
vt.config.driver = _tx.drv
return vt
}
// String implements the fmt.Stringer.
func (vt *VerifyToken) String() string {
var builder strings.Builder
builder.WriteString("VerifyToken(")
builder.WriteString(fmt.Sprintf("id=%v, ", vt.ID))
builder.WriteString("created_at=")
builder.WriteString(vt.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("expires_at=")
builder.WriteString(vt.ExpiresAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("token=")
builder.WriteString(vt.Token)
builder.WriteString(", ")
builder.WriteString("purpose=")
builder.WriteString(vt.Purpose)
builder.WriteByte(')')
return builder.String()
}
// VerifyTokens is a parsable slice of VerifyToken.
type VerifyTokens []*VerifyToken