versia-go/ent/image.go

115 lines
3.3 KiB
Go
Raw Normal View History

2024-08-11 03:51:22 +02:00
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
2024-08-28 00:25:25 +02:00
"github.com/versia-pub/versia-go/ent/image"
2024-08-11 03:51:22 +02:00
)
// Image is the model entity for the Image schema.
type Image struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// MimeType holds the value of the "mimeType" field.
MimeType string `json:"mimeType,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Image) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case image.FieldID:
values[i] = new(sql.NullInt64)
case image.FieldURL, image.FieldMimeType:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Image fields.
func (i *Image) 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 j := range columns {
switch columns[j] {
case image.FieldID:
value, ok := values[j].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
i.ID = int(value.Int64)
case image.FieldURL:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[j])
} else if value.Valid {
i.URL = value.String
}
case image.FieldMimeType:
if value, ok := values[j].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field mimeType", values[j])
} else if value.Valid {
i.MimeType = value.String
}
default:
i.selectValues.Set(columns[j], values[j])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Image.
// This includes values selected through modifiers, order, etc.
func (i *Image) Value(name string) (ent.Value, error) {
return i.selectValues.Get(name)
}
// Update returns a builder for updating this Image.
// Note that you need to call Image.Unwrap() before calling this method if this Image
// was returned from a transaction, and the transaction was committed or rolled back.
func (i *Image) Update() *ImageUpdateOne {
return NewImageClient(i.config).UpdateOne(i)
}
// Unwrap unwraps the Image 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 (i *Image) Unwrap() *Image {
_tx, ok := i.config.driver.(*txDriver)
if !ok {
panic("ent: Image is not a transactional entity")
}
i.config.driver = _tx.drv
return i
}
// String implements the fmt.Stringer.
func (i *Image) String() string {
var builder strings.Builder
builder.WriteString("Image(")
builder.WriteString(fmt.Sprintf("id=%v, ", i.ID))
builder.WriteString("url=")
builder.WriteString(i.URL)
builder.WriteString(", ")
builder.WriteString("mimeType=")
builder.WriteString(i.MimeType)
builder.WriteByte(')')
return builder.String()
}
// Images is a parsable slice of Image.
type Images []*Image