420 lines
13 KiB
Go
420 lines
13 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package query
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"kra/internal/data/model"
|
|
)
|
|
|
|
func newExaFileChunk(db *gorm.DB, opts ...gen.DOOption) exaFileChunk {
|
|
_exaFileChunk := exaFileChunk{}
|
|
|
|
_exaFileChunk.exaFileChunkDo.UseDB(db, opts...)
|
|
_exaFileChunk.exaFileChunkDo.UseModel(&model.ExaFileChunk{})
|
|
|
|
tableName := _exaFileChunk.exaFileChunkDo.TableName()
|
|
_exaFileChunk.ALL = field.NewAsterisk(tableName)
|
|
_exaFileChunk.ID = field.NewInt64(tableName, "id")
|
|
_exaFileChunk.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_exaFileChunk.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_exaFileChunk.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_exaFileChunk.ExaFileID = field.NewInt64(tableName, "exa_file_id")
|
|
_exaFileChunk.FileChunkNumber = field.NewInt64(tableName, "file_chunk_number")
|
|
_exaFileChunk.FileChunkPath = field.NewString(tableName, "file_chunk_path")
|
|
|
|
_exaFileChunk.fillFieldMap()
|
|
|
|
return _exaFileChunk
|
|
}
|
|
|
|
type exaFileChunk struct {
|
|
exaFileChunkDo exaFileChunkDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
DeletedAt field.Field
|
|
ExaFileID field.Int64
|
|
FileChunkNumber field.Int64
|
|
FileChunkPath field.String
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (e exaFileChunk) Table(newTableName string) *exaFileChunk {
|
|
e.exaFileChunkDo.UseTable(newTableName)
|
|
return e.updateTableName(newTableName)
|
|
}
|
|
|
|
func (e exaFileChunk) As(alias string) *exaFileChunk {
|
|
e.exaFileChunkDo.DO = *(e.exaFileChunkDo.As(alias).(*gen.DO))
|
|
return e.updateTableName(alias)
|
|
}
|
|
|
|
func (e *exaFileChunk) updateTableName(table string) *exaFileChunk {
|
|
e.ALL = field.NewAsterisk(table)
|
|
e.ID = field.NewInt64(table, "id")
|
|
e.CreatedAt = field.NewTime(table, "created_at")
|
|
e.UpdatedAt = field.NewTime(table, "updated_at")
|
|
e.DeletedAt = field.NewField(table, "deleted_at")
|
|
e.ExaFileID = field.NewInt64(table, "exa_file_id")
|
|
e.FileChunkNumber = field.NewInt64(table, "file_chunk_number")
|
|
e.FileChunkPath = field.NewString(table, "file_chunk_path")
|
|
|
|
e.fillFieldMap()
|
|
|
|
return e
|
|
}
|
|
|
|
func (e *exaFileChunk) WithContext(ctx context.Context) IExaFileChunkDo {
|
|
return e.exaFileChunkDo.WithContext(ctx)
|
|
}
|
|
|
|
func (e exaFileChunk) TableName() string { return e.exaFileChunkDo.TableName() }
|
|
|
|
func (e exaFileChunk) Alias() string { return e.exaFileChunkDo.Alias() }
|
|
|
|
func (e exaFileChunk) Columns(cols ...field.Expr) gen.Columns {
|
|
return e.exaFileChunkDo.Columns(cols...)
|
|
}
|
|
|
|
func (e *exaFileChunk) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := e.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (e *exaFileChunk) fillFieldMap() {
|
|
e.fieldMap = make(map[string]field.Expr, 7)
|
|
e.fieldMap["id"] = e.ID
|
|
e.fieldMap["created_at"] = e.CreatedAt
|
|
e.fieldMap["updated_at"] = e.UpdatedAt
|
|
e.fieldMap["deleted_at"] = e.DeletedAt
|
|
e.fieldMap["exa_file_id"] = e.ExaFileID
|
|
e.fieldMap["file_chunk_number"] = e.FileChunkNumber
|
|
e.fieldMap["file_chunk_path"] = e.FileChunkPath
|
|
}
|
|
|
|
func (e exaFileChunk) clone(db *gorm.DB) exaFileChunk {
|
|
e.exaFileChunkDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return e
|
|
}
|
|
|
|
func (e exaFileChunk) replaceDB(db *gorm.DB) exaFileChunk {
|
|
e.exaFileChunkDo.ReplaceDB(db)
|
|
return e
|
|
}
|
|
|
|
type exaFileChunkDo struct{ gen.DO }
|
|
|
|
type IExaFileChunkDo interface {
|
|
gen.SubQuery
|
|
Debug() IExaFileChunkDo
|
|
WithContext(ctx context.Context) IExaFileChunkDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IExaFileChunkDo
|
|
WriteDB() IExaFileChunkDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IExaFileChunkDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IExaFileChunkDo
|
|
Not(conds ...gen.Condition) IExaFileChunkDo
|
|
Or(conds ...gen.Condition) IExaFileChunkDo
|
|
Select(conds ...field.Expr) IExaFileChunkDo
|
|
Where(conds ...gen.Condition) IExaFileChunkDo
|
|
Order(conds ...field.Expr) IExaFileChunkDo
|
|
Distinct(cols ...field.Expr) IExaFileChunkDo
|
|
Omit(cols ...field.Expr) IExaFileChunkDo
|
|
Join(table schema.Tabler, on ...field.Expr) IExaFileChunkDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IExaFileChunkDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IExaFileChunkDo
|
|
Group(cols ...field.Expr) IExaFileChunkDo
|
|
Having(conds ...gen.Condition) IExaFileChunkDo
|
|
Limit(limit int) IExaFileChunkDo
|
|
Offset(offset int) IExaFileChunkDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IExaFileChunkDo
|
|
Unscoped() IExaFileChunkDo
|
|
Create(values ...*model.ExaFileChunk) error
|
|
CreateInBatches(values []*model.ExaFileChunk, batchSize int) error
|
|
Save(values ...*model.ExaFileChunk) error
|
|
First() (*model.ExaFileChunk, error)
|
|
Take() (*model.ExaFileChunk, error)
|
|
Last() (*model.ExaFileChunk, error)
|
|
Find() ([]*model.ExaFileChunk, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaFileChunk, err error)
|
|
FindInBatches(result *[]*model.ExaFileChunk, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.ExaFileChunk) (info gen.ResultInfo, err error)
|
|
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
Updates(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
|
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
|
UpdateFrom(q gen.SubQuery) gen.Dao
|
|
Attrs(attrs ...field.AssignExpr) IExaFileChunkDo
|
|
Assign(attrs ...field.AssignExpr) IExaFileChunkDo
|
|
Joins(fields ...field.RelationField) IExaFileChunkDo
|
|
Preload(fields ...field.RelationField) IExaFileChunkDo
|
|
FirstOrInit() (*model.ExaFileChunk, error)
|
|
FirstOrCreate() (*model.ExaFileChunk, error)
|
|
FindByPage(offset int, limit int) (result []*model.ExaFileChunk, count int64, err error)
|
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
|
Rows() (*sql.Rows, error)
|
|
Row() *sql.Row
|
|
Scan(result interface{}) (err error)
|
|
Returning(value interface{}, columns ...string) IExaFileChunkDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (e exaFileChunkDo) Debug() IExaFileChunkDo {
|
|
return e.withDO(e.DO.Debug())
|
|
}
|
|
|
|
func (e exaFileChunkDo) WithContext(ctx context.Context) IExaFileChunkDo {
|
|
return e.withDO(e.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (e exaFileChunkDo) ReadDB() IExaFileChunkDo {
|
|
return e.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (e exaFileChunkDo) WriteDB() IExaFileChunkDo {
|
|
return e.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (e exaFileChunkDo) Session(config *gorm.Session) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Session(config))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Clauses(conds ...clause.Expression) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Returning(value interface{}, columns ...string) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Not(conds ...gen.Condition) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Not(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Or(conds ...gen.Condition) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Or(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Select(conds ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Select(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Where(conds ...gen.Condition) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Where(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Order(conds ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Order(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Distinct(cols ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Omit(cols ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Omit(cols...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Join(table schema.Tabler, on ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Join(table, on...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) RightJoin(table schema.Tabler, on ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Group(cols ...field.Expr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Group(cols...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Having(conds ...gen.Condition) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Having(conds...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Limit(limit int) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Limit(limit))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Offset(offset int) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Offset(offset))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Unscoped() IExaFileChunkDo {
|
|
return e.withDO(e.DO.Unscoped())
|
|
}
|
|
|
|
func (e exaFileChunkDo) Create(values ...*model.ExaFileChunk) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return e.DO.Create(values)
|
|
}
|
|
|
|
func (e exaFileChunkDo) CreateInBatches(values []*model.ExaFileChunk, batchSize int) error {
|
|
return e.DO.CreateInBatches(values, batchSize)
|
|
}
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
func (e exaFileChunkDo) Save(values ...*model.ExaFileChunk) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return e.DO.Save(values)
|
|
}
|
|
|
|
func (e exaFileChunkDo) First() (*model.ExaFileChunk, error) {
|
|
if result, err := e.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFileChunk), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileChunkDo) Take() (*model.ExaFileChunk, error) {
|
|
if result, err := e.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFileChunk), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileChunkDo) Last() (*model.ExaFileChunk, error) {
|
|
if result, err := e.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFileChunk), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileChunkDo) Find() ([]*model.ExaFileChunk, error) {
|
|
result, err := e.DO.Find()
|
|
return result.([]*model.ExaFileChunk), err
|
|
}
|
|
|
|
func (e exaFileChunkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaFileChunk, err error) {
|
|
buf := make([]*model.ExaFileChunk, 0, batchSize)
|
|
err = e.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
defer func() { results = append(results, buf...) }()
|
|
return fc(tx, batch)
|
|
})
|
|
return results, err
|
|
}
|
|
|
|
func (e exaFileChunkDo) FindInBatches(result *[]*model.ExaFileChunk, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return e.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (e exaFileChunkDo) Attrs(attrs ...field.AssignExpr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Assign(attrs ...field.AssignExpr) IExaFileChunkDo {
|
|
return e.withDO(e.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (e exaFileChunkDo) Joins(fields ...field.RelationField) IExaFileChunkDo {
|
|
for _, _f := range fields {
|
|
e = *e.withDO(e.DO.Joins(_f))
|
|
}
|
|
return &e
|
|
}
|
|
|
|
func (e exaFileChunkDo) Preload(fields ...field.RelationField) IExaFileChunkDo {
|
|
for _, _f := range fields {
|
|
e = *e.withDO(e.DO.Preload(_f))
|
|
}
|
|
return &e
|
|
}
|
|
|
|
func (e exaFileChunkDo) FirstOrInit() (*model.ExaFileChunk, error) {
|
|
if result, err := e.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFileChunk), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileChunkDo) FirstOrCreate() (*model.ExaFileChunk, error) {
|
|
if result, err := e.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFileChunk), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileChunkDo) FindByPage(offset int, limit int) (result []*model.ExaFileChunk, count int64, err error) {
|
|
result, err = e.Offset(offset).Limit(limit).Find()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
count = int64(size + offset)
|
|
return
|
|
}
|
|
|
|
count, err = e.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (e exaFileChunkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = e.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = e.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (e exaFileChunkDo) Scan(result interface{}) (err error) {
|
|
return e.DO.Scan(result)
|
|
}
|
|
|
|
func (e exaFileChunkDo) Delete(models ...*model.ExaFileChunk) (result gen.ResultInfo, err error) {
|
|
return e.DO.Delete(models)
|
|
}
|
|
|
|
func (e *exaFileChunkDo) withDO(do gen.Dao) *exaFileChunkDo {
|
|
e.DO = *do.(*gen.DO)
|
|
return e
|
|
}
|