This commit is contained in:
59
backend_v1/database/models/medias.gen.go
Normal file
59
backend_v1/database/models/medias.gen.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
const TableNameMedia = "medias"
|
||||
|
||||
// Media mapped from table <medias>
|
||||
type Media struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp without time zone;not null;default:now()" json:"created_at"`
|
||||
Name string `gorm:"column:name;type:character varying(255);not null" json:"name"`
|
||||
MimeType string `gorm:"column:mime_type;type:character varying(128);not null" json:"mime_type"`
|
||||
Size int64 `gorm:"column:size;type:bigint;not null" json:"size"`
|
||||
Path string `gorm:"column:path;type:character varying(255);not null" json:"path"`
|
||||
Metas types.JSON `gorm:"column:metas;type:jsonb;not null;default:{}" json:"metas"`
|
||||
Hash string `gorm:"column:hash;type:character varying(64);not null" json:"hash"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
// Update applies changed fields to the database using the default DB.
|
||||
func (m *Media) Update(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Media.WithContext(ctx).Updates(m)
|
||||
}
|
||||
|
||||
// Save upserts the model using the default DB.
|
||||
func (m *Media) Save(ctx context.Context) error { return Q.Media.WithContext(ctx).Save(m) }
|
||||
|
||||
// Create inserts the model using the default DB.
|
||||
func (m *Media) Create(ctx context.Context) error { return Q.Media.WithContext(ctx).Create(m) }
|
||||
|
||||
// Delete removes the row represented by the model using the default DB.
|
||||
func (m *Media) Delete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Media.WithContext(ctx).Delete(m)
|
||||
}
|
||||
|
||||
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
|
||||
func (m *Media) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.Media.WithContext(ctx).Unscoped().Delete(m)
|
||||
}
|
||||
|
||||
// Reload reloads the model from database by its primary key and overwrites current fields.
|
||||
func (m *Media) Reload(ctx context.Context) error {
|
||||
fresh, err := Q.Media.WithContext(ctx).GetByID(m.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*m = *fresh
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user