143 lines
4.4 KiB
Go
143 lines
4.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/xmdhs/authlib-skin/db/ent/user"
|
|
"github.com/xmdhs/authlib-skin/db/ent/usertoken"
|
|
)
|
|
|
|
// UserToken is the model entity for the UserToken schema.
|
|
type UserToken struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// TokenID holds the value of the "token_id" field.
|
|
TokenID uint64 `json:"token_id,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the UserTokenQuery when eager-loading is set.
|
|
Edges UserTokenEdges `json:"edges"`
|
|
user_token *int
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// UserTokenEdges holds the relations/edges for other nodes in the graph.
|
|
type UserTokenEdges 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 UserTokenEdges) 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 (*UserToken) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case usertoken.FieldID, usertoken.FieldTokenID:
|
|
values[i] = new(sql.NullInt64)
|
|
case usertoken.ForeignKeys[0]: // user_token
|
|
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 UserToken fields.
|
|
func (ut *UserToken) 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 usertoken.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
ut.ID = int(value.Int64)
|
|
case usertoken.FieldTokenID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field token_id", values[i])
|
|
} else if value.Valid {
|
|
ut.TokenID = uint64(value.Int64)
|
|
}
|
|
case usertoken.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for edge-field user_token", value)
|
|
} else if value.Valid {
|
|
ut.user_token = new(int)
|
|
*ut.user_token = int(value.Int64)
|
|
}
|
|
default:
|
|
ut.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the UserToken.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (ut *UserToken) Value(name string) (ent.Value, error) {
|
|
return ut.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the UserToken entity.
|
|
func (ut *UserToken) QueryUser() *UserQuery {
|
|
return NewUserTokenClient(ut.config).QueryUser(ut)
|
|
}
|
|
|
|
// Update returns a builder for updating this UserToken.
|
|
// Note that you need to call UserToken.Unwrap() before calling this method if this UserToken
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (ut *UserToken) Update() *UserTokenUpdateOne {
|
|
return NewUserTokenClient(ut.config).UpdateOne(ut)
|
|
}
|
|
|
|
// Unwrap unwraps the UserToken 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 (ut *UserToken) Unwrap() *UserToken {
|
|
_tx, ok := ut.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: UserToken is not a transactional entity")
|
|
}
|
|
ut.config.driver = _tx.drv
|
|
return ut
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (ut *UserToken) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("UserToken(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", ut.ID))
|
|
builder.WriteString("token_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", ut.TokenID))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// UserTokens is a parsable slice of UserToken.
|
|
type UserTokens []*UserToken
|