[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
222
backend/ent/media.go
Normal file
222
backend/ent/media.go
Normal file
|
@ -0,0 +1,222 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"tss-rocks-be/ent/media"
|
||||
"tss-rocks-be/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Media is the model entity for the Media schema.
|
||||
type Media struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// StorageID holds the value of the "storage_id" field.
|
||||
StorageID string `json:"storage_id,omitempty"`
|
||||
// OriginalName holds the value of the "original_name" field.
|
||||
OriginalName string `json:"original_name,omitempty"`
|
||||
// MimeType holds the value of the "mime_type" field.
|
||||
MimeType string `json:"mime_type,omitempty"`
|
||||
// Size holds the value of the "size" field.
|
||||
Size int64 `json:"size,omitempty"`
|
||||
// URL holds the value of the "url" field.
|
||||
URL string `json:"url,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"`
|
||||
// CreatedBy holds the value of the "created_by" field.
|
||||
CreatedBy string `json:"created_by,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the MediaQuery when eager-loading is set.
|
||||
Edges MediaEdges `json:"edges"`
|
||||
user_media *int
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// MediaEdges holds the relations/edges for other nodes in the graph.
|
||||
type MediaEdges 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 MediaEdges) OwnerOrErr() (*User, error) {
|
||||
if e.Owner != nil {
|
||||
return e.Owner, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: user.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "owner"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Media) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case media.FieldID, media.FieldSize:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case media.FieldStorageID, media.FieldOriginalName, media.FieldMimeType, media.FieldURL, media.FieldCreatedBy:
|
||||
values[i] = new(sql.NullString)
|
||||
case media.FieldCreatedAt, media.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case media.ForeignKeys[0]: // user_media
|
||||
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 Media fields.
|
||||
func (m *Media) 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 media.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 media.FieldStorageID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field storage_id", values[i])
|
||||
} else if value.Valid {
|
||||
m.StorageID = value.String
|
||||
}
|
||||
case media.FieldOriginalName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field original_name", values[i])
|
||||
} else if value.Valid {
|
||||
m.OriginalName = value.String
|
||||
}
|
||||
case media.FieldMimeType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mime_type", values[i])
|
||||
} else if value.Valid {
|
||||
m.MimeType = value.String
|
||||
}
|
||||
case media.FieldSize:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field size", values[i])
|
||||
} else if value.Valid {
|
||||
m.Size = value.Int64
|
||||
}
|
||||
case media.FieldURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field url", values[i])
|
||||
} else if value.Valid {
|
||||
m.URL = value.String
|
||||
}
|
||||
case media.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 media.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 media.FieldCreatedBy:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_by", values[i])
|
||||
} else if value.Valid {
|
||||
m.CreatedBy = value.String
|
||||
}
|
||||
case media.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field user_media", value)
|
||||
} else if value.Valid {
|
||||
m.user_media = new(int)
|
||||
*m.user_media = 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 Media.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (m *Media) Value(name string) (ent.Value, error) {
|
||||
return m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryOwner queries the "owner" edge of the Media entity.
|
||||
func (m *Media) QueryOwner() *UserQuery {
|
||||
return NewMediaClient(m.config).QueryOwner(m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Media.
|
||||
// Note that you need to call Media.Unwrap() before calling this method if this Media
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (m *Media) Update() *MediaUpdateOne {
|
||||
return NewMediaClient(m.config).UpdateOne(m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Media 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 *Media) Unwrap() *Media {
|
||||
_tx, ok := m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Media is not a transactional entity")
|
||||
}
|
||||
m.config.driver = _tx.drv
|
||||
return m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (m *Media) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Media(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||
builder.WriteString("storage_id=")
|
||||
builder.WriteString(m.StorageID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("original_name=")
|
||||
builder.WriteString(m.OriginalName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mime_type=")
|
||||
builder.WriteString(m.MimeType)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("size=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Size))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("url=")
|
||||
builder.WriteString(m.URL)
|
||||
builder.WriteString(", ")
|
||||
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(", ")
|
||||
builder.WriteString("created_by=")
|
||||
builder.WriteString(m.CreatedBy)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// MediaSlice is a parsable slice of Media.
|
||||
type MediaSlice []*Media
|
Loading…
Add table
Add a link
Reference in a new issue