1
0
api/ent/sev.go
2024-04-11 10:14:25 +09:00

269 lines
8.6 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"api/ent/sev"
"api/ent/user"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Sev is the model entity for the Sev schema.
type Sev struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Password holds the value of the "password" field.
Password string `json:"-"`
// Token holds the value of the "token" field.
Token string `json:"-"`
// Limit holds the value of the "limit" field.
Limit bool `json:"limit,omitempty"`
// Count holds the value of the "count" field.
Count int `json:"count,omitempty"`
// Handle holds the value of the "handle" field.
Handle string `json:"handle,omitempty"`
// Did holds the value of the "did" field.
Did string `json:"did,omitempty"`
// UID holds the value of the "uid" field.
UID int `json:"uid,omitempty"`
// Cid holds the value of the "cid" field.
Cid int `json:"cid,omitempty"`
// Cp holds the value of the "cp" field.
Cp int `json:"cp,omitempty"`
// Card holds the value of the "card" field.
Card int `json:"card,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the SevQuery when eager-loading is set.
Edges SevEdges `json:"edges"`
user_sev *int
selectValues sql.SelectValues
}
// SevEdges holds the relations/edges for other nodes in the graph.
type SevEdges struct {
// Owner holds the value of the owner edge.
Owner *User `json:"owner,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// OwnerOrErr returns the Owner value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e SevEdges) OwnerOrErr() (*User, error) {
if e.loadedTypes[0] {
if e.Owner == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: user.Label}
}
return e.Owner, nil
}
return nil, &NotLoadedError{edge: "owner"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Sev) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case sev.FieldLimit:
values[i] = new(sql.NullBool)
case sev.FieldID, sev.FieldCount, sev.FieldUID, sev.FieldCid, sev.FieldCp, sev.FieldCard:
values[i] = new(sql.NullInt64)
case sev.FieldPassword, sev.FieldToken, sev.FieldHandle, sev.FieldDid:
values[i] = new(sql.NullString)
case sev.FieldUpdatedAt, sev.FieldCreatedAt:
values[i] = new(sql.NullTime)
case sev.ForeignKeys[0]: // user_sev
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 Sev fields.
func (s *Sev) 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 sev.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
s.ID = int(value.Int64)
case sev.FieldPassword:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
} else if value.Valid {
s.Password = value.String
}
case sev.FieldToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i])
} else if value.Valid {
s.Token = value.String
}
case sev.FieldLimit:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field limit", values[i])
} else if value.Valid {
s.Limit = value.Bool
}
case sev.FieldCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field count", values[i])
} else if value.Valid {
s.Count = int(value.Int64)
}
case sev.FieldHandle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field handle", values[i])
} else if value.Valid {
s.Handle = value.String
}
case sev.FieldDid:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field did", values[i])
} else if value.Valid {
s.Did = value.String
}
case sev.FieldUID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field uid", values[i])
} else if value.Valid {
s.UID = int(value.Int64)
}
case sev.FieldCid:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field cid", values[i])
} else if value.Valid {
s.Cid = int(value.Int64)
}
case sev.FieldCp:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field cp", values[i])
} else if value.Valid {
s.Cp = int(value.Int64)
}
case sev.FieldCard:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field card", values[i])
} else if value.Valid {
s.Card = int(value.Int64)
}
case sev.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
s.UpdatedAt = value.Time
}
case sev.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 {
s.CreatedAt = value.Time
}
case sev.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field user_sev", value)
} else if value.Valid {
s.user_sev = new(int)
*s.user_sev = int(value.Int64)
}
default:
s.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Sev.
// This includes values selected through modifiers, order, etc.
func (s *Sev) Value(name string) (ent.Value, error) {
return s.selectValues.Get(name)
}
// QueryOwner queries the "owner" edge of the Sev entity.
func (s *Sev) QueryOwner() *UserQuery {
return NewSevClient(s.config).QueryOwner(s)
}
// Update returns a builder for updating this Sev.
// Note that you need to call Sev.Unwrap() before calling this method if this Sev
// was returned from a transaction, and the transaction was committed or rolled back.
func (s *Sev) Update() *SevUpdateOne {
return NewSevClient(s.config).UpdateOne(s)
}
// Unwrap unwraps the Sev 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 (s *Sev) Unwrap() *Sev {
_tx, ok := s.config.driver.(*txDriver)
if !ok {
panic("ent: Sev is not a transactional entity")
}
s.config.driver = _tx.drv
return s
}
// String implements the fmt.Stringer.
func (s *Sev) String() string {
var builder strings.Builder
builder.WriteString("Sev(")
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
builder.WriteString("password=<sensitive>")
builder.WriteString(", ")
builder.WriteString("token=<sensitive>")
builder.WriteString(", ")
builder.WriteString("limit=")
builder.WriteString(fmt.Sprintf("%v", s.Limit))
builder.WriteString(", ")
builder.WriteString("count=")
builder.WriteString(fmt.Sprintf("%v", s.Count))
builder.WriteString(", ")
builder.WriteString("handle=")
builder.WriteString(s.Handle)
builder.WriteString(", ")
builder.WriteString("did=")
builder.WriteString(s.Did)
builder.WriteString(", ")
builder.WriteString("uid=")
builder.WriteString(fmt.Sprintf("%v", s.UID))
builder.WriteString(", ")
builder.WriteString("cid=")
builder.WriteString(fmt.Sprintf("%v", s.Cid))
builder.WriteString(", ")
builder.WriteString("cp=")
builder.WriteString(fmt.Sprintf("%v", s.Cp))
builder.WriteString(", ")
builder.WriteString("card=")
builder.WriteString(fmt.Sprintf("%v", s.Card))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(s.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(s.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// Sevs is a parsable slice of Sev.
type Sevs []*Sev