Init V4 community edition (#2265)
* Init V4 community edition * Init V4 community edition
This commit is contained in:
214
ent/metadata.go
Normal file
214
ent/metadata.go
Normal file
@@ -0,0 +1,214 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/cloudreve/Cloudreve/v4/ent/file"
|
||||
"github.com/cloudreve/Cloudreve/v4/ent/metadata"
|
||||
)
|
||||
|
||||
// Metadata is the model entity for the Metadata schema.
|
||||
type Metadata struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Value holds the value of the "value" field.
|
||||
Value string `json:"value,omitempty"`
|
||||
// FileID holds the value of the "file_id" field.
|
||||
FileID int `json:"file_id,omitempty"`
|
||||
// IsPublic holds the value of the "is_public" field.
|
||||
IsPublic bool `json:"is_public,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the MetadataQuery when eager-loading is set.
|
||||
Edges MetadataEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// MetadataEdges holds the relations/edges for other nodes in the graph.
|
||||
type MetadataEdges struct {
|
||||
// File holds the value of the file edge.
|
||||
File *File `json:"file,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// FileOrErr returns the File value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e MetadataEdges) FileOrErr() (*File, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.File == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: file.Label}
|
||||
}
|
||||
return e.File, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "file"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Metadata) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case metadata.FieldIsPublic:
|
||||
values[i] = new(sql.NullBool)
|
||||
case metadata.FieldID, metadata.FieldFileID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case metadata.FieldName, metadata.FieldValue:
|
||||
values[i] = new(sql.NullString)
|
||||
case metadata.FieldCreatedAt, metadata.FieldUpdatedAt, metadata.FieldDeletedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Metadata fields.
|
||||
func (m *Metadata) 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 metadata.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 metadata.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 metadata.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 metadata.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
m.DeletedAt = new(time.Time)
|
||||
*m.DeletedAt = value.Time
|
||||
}
|
||||
case metadata.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
m.Name = value.String
|
||||
}
|
||||
case metadata.FieldValue:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field value", values[i])
|
||||
} else if value.Valid {
|
||||
m.Value = value.String
|
||||
}
|
||||
case metadata.FieldFileID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field file_id", values[i])
|
||||
} else if value.Valid {
|
||||
m.FileID = int(value.Int64)
|
||||
}
|
||||
case metadata.FieldIsPublic:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field is_public", values[i])
|
||||
} else if value.Valid {
|
||||
m.IsPublic = value.Bool
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns the ent.Value that was dynamically selected and assigned to the Metadata.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (m *Metadata) GetValue(name string) (ent.Value, error) {
|
||||
return m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryFile queries the "file" edge of the Metadata entity.
|
||||
func (m *Metadata) QueryFile() *FileQuery {
|
||||
return NewMetadataClient(m.config).QueryFile(m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Metadata.
|
||||
// Note that you need to call Metadata.Unwrap() before calling this method if this Metadata
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (m *Metadata) Update() *MetadataUpdateOne {
|
||||
return NewMetadataClient(m.config).UpdateOne(m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Metadata 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 *Metadata) Unwrap() *Metadata {
|
||||
_tx, ok := m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Metadata is not a transactional entity")
|
||||
}
|
||||
m.config.driver = _tx.drv
|
||||
return m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (m *Metadata) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Metadata(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(m.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
if v := m.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("value=")
|
||||
builder.WriteString(m.Value)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("file_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.FileID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("is_public=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.IsPublic))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// SetFile manually set the edge as loaded state.
|
||||
func (e *Metadata) SetFile(v *File) {
|
||||
e.Edges.File = v
|
||||
e.Edges.loadedTypes[0] = true
|
||||
}
|
||||
|
||||
// MetadataSlice is a parsable slice of Metadata.
|
||||
type MetadataSlice []*Metadata
|
||||
Reference in New Issue
Block a user