// 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" "quyun/v2/pkg/fields" "go.ipao.vip/gen" "go.ipao.vip/gen/types" ) const TableNameMedium = "media" // Medium mapped from table type Medium 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.JSONType[fields.MediaMetas] `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 *Medium) Update(ctx context.Context) (gen.ResultInfo, error) { return Q.Medium.WithContext(ctx).Updates(m) } // Save upserts the model using the default DB. func (m *Medium) Save(ctx context.Context) error { return Q.Medium.WithContext(ctx).Save(m) } // Create inserts the model using the default DB. func (m *Medium) Create(ctx context.Context) error { return Q.Medium.WithContext(ctx).Create(m) } // Delete removes the row represented by the model using the default DB. func (m *Medium) Delete(ctx context.Context) (gen.ResultInfo, error) { return Q.Medium.WithContext(ctx).Delete(m) } // ForceDelete permanently deletes the row (ignores soft delete) using the default DB. func (m *Medium) ForceDelete(ctx context.Context) (gen.ResultInfo, error) { return Q.Medium.WithContext(ctx).Unscoped().Delete(m) } // Reload reloads the model from database by its primary key and overwrites current fields. func (m *Medium) Reload(ctx context.Context) error { fresh, err := Q.Medium.WithContext(ctx).GetByID(m.ID) if err != nil { return err } *m = *fresh return nil }