1
0
api/ent/ma.go
2024-04-02 18:57:04 +09:00

291 lines
9.3 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"api/ent/ma"
"api/ent/user"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Ma is the model entity for the Ma schema.
type Ma 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"`
// Text holds the value of the "text" field.
Text string `json:"text,omitempty"`
// Did holds the value of the "did" field.
Did string `json:"did,omitempty"`
// Avatar holds the value of the "avatar" field.
Avatar string `json:"avatar,omitempty"`
// Cid holds the value of the "cid" field.
Cid string `json:"cid,omitempty"`
// URI holds the value of the "uri" field.
URI string `json:"uri,omitempty"`
// Rkey holds the value of the "rkey" field.
Rkey string `json:"rkey,omitempty"`
// BskyURL holds the value of the "bsky_url" field.
BskyURL string `json:"bsky_url,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 MaQuery when eager-loading is set.
Edges MaEdges `json:"edges"`
user_ma *int
selectValues sql.SelectValues
}
// MaEdges holds the relations/edges for other nodes in the graph.
type MaEdges 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 MaEdges) 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 (*Ma) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case ma.FieldLimit:
values[i] = new(sql.NullBool)
case ma.FieldID, ma.FieldCount:
values[i] = new(sql.NullInt64)
case ma.FieldPassword, ma.FieldToken, ma.FieldHandle, ma.FieldText, ma.FieldDid, ma.FieldAvatar, ma.FieldCid, ma.FieldURI, ma.FieldRkey, ma.FieldBskyURL:
values[i] = new(sql.NullString)
case ma.FieldUpdatedAt, ma.FieldCreatedAt:
values[i] = new(sql.NullTime)
case ma.ForeignKeys[0]: // user_ma
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 Ma fields.
func (m *Ma) 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 ma.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
m.ID = int(value.Int64)
case ma.FieldPassword:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
} else if value.Valid {
m.Password = value.String
}
case ma.FieldToken:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field token", values[i])
} else if value.Valid {
m.Token = value.String
}
case ma.FieldLimit:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field limit", values[i])
} else if value.Valid {
m.Limit = value.Bool
}
case ma.FieldCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field count", values[i])
} else if value.Valid {
m.Count = int(value.Int64)
}
case ma.FieldHandle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field handle", values[i])
} else if value.Valid {
m.Handle = value.String
}
case ma.FieldText:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field text", values[i])
} else if value.Valid {
m.Text = value.String
}
case ma.FieldDid:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field did", values[i])
} else if value.Valid {
m.Did = value.String
}
case ma.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field avatar", values[i])
} else if value.Valid {
m.Avatar = value.String
}
case ma.FieldCid:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field cid", values[i])
} else if value.Valid {
m.Cid = value.String
}
case ma.FieldURI:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uri", values[i])
} else if value.Valid {
m.URI = value.String
}
case ma.FieldRkey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field rkey", values[i])
} else if value.Valid {
m.Rkey = value.String
}
case ma.FieldBskyURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field bsky_url", values[i])
} else if value.Valid {
m.BskyURL = value.String
}
case ma.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 {
m.UpdatedAt = value.Time
}
case ma.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 {
m.CreatedAt = value.Time
}
case ma.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field user_ma", value)
} else if value.Valid {
m.user_ma = new(int)
*m.user_ma = int(value.Int64)
}
default:
m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Ma.
// This includes values selected through modifiers, order, etc.
func (m *Ma) Value(name string) (ent.Value, error) {
return m.selectValues.Get(name)
}
// QueryOwner queries the "owner" edge of the Ma entity.
func (m *Ma) QueryOwner() *UserQuery {
return NewMaClient(m.config).QueryOwner(m)
}
// Update returns a builder for updating this Ma.
// Note that you need to call Ma.Unwrap() before calling this method if this Ma
// was returned from a transaction, and the transaction was committed or rolled back.
func (m *Ma) Update() *MaUpdateOne {
return NewMaClient(m.config).UpdateOne(m)
}
// Unwrap unwraps the Ma 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 (m *Ma) Unwrap() *Ma {
_tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Ma is not a transactional entity")
}
m.config.driver = _tx.drv
return m
}
// String implements the fmt.Stringer.
func (m *Ma) String() string {
var builder strings.Builder
builder.WriteString("Ma(")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
builder.WriteString("password=<sensitive>")
builder.WriteString(", ")
builder.WriteString("token=<sensitive>")
builder.WriteString(", ")
builder.WriteString("limit=")
builder.WriteString(fmt.Sprintf("%v", m.Limit))
builder.WriteString(", ")
builder.WriteString("count=")
builder.WriteString(fmt.Sprintf("%v", m.Count))
builder.WriteString(", ")
builder.WriteString("handle=")
builder.WriteString(m.Handle)
builder.WriteString(", ")
builder.WriteString("text=")
builder.WriteString(m.Text)
builder.WriteString(", ")
builder.WriteString("did=")
builder.WriteString(m.Did)
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(m.Avatar)
builder.WriteString(", ")
builder.WriteString("cid=")
builder.WriteString(m.Cid)
builder.WriteString(", ")
builder.WriteString("uri=")
builder.WriteString(m.URI)
builder.WriteString(", ")
builder.WriteString("rkey=")
builder.WriteString(m.Rkey)
builder.WriteString(", ")
builder.WriteString("bsky_url=")
builder.WriteString(m.BskyURL)
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// Mas is a parsable slice of Ma.
type Mas []*Ma