Files
vt/query/scanobjects.gen.go
2025-08-12 18:10:43 +02:00

396 lines
11 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"
"git.kocoder.xyz/kocoded/vt/model"
)
func newScanobject(db *gorm.DB, opts ...gen.DOOption) scanobject {
_scanobject := scanobject{}
_scanobject.scanobjectDo.UseDB(db, opts...)
_scanobject.scanobjectDo.UseModel(&model.Scanobject{})
tableName := _scanobject.scanobjectDo.TableName()
_scanobject.ALL = field.NewAsterisk(tableName)
_scanobject.ID = field.NewUint(tableName, "id")
_scanobject.CreatedAt = field.NewTime(tableName, "created_at")
_scanobject.UpdatedAt = field.NewTime(tableName, "updated_at")
_scanobject.DeletedAt = field.NewField(tableName, "deleted_at")
_scanobject.fillFieldMap()
return _scanobject
}
type scanobject struct {
scanobjectDo
ALL field.Asterisk
ID field.Uint
CreatedAt field.Time
UpdatedAt field.Time
DeletedAt field.Field
fieldMap map[string]field.Expr
}
func (s scanobject) Table(newTableName string) *scanobject {
s.scanobjectDo.UseTable(newTableName)
return s.updateTableName(newTableName)
}
func (s scanobject) As(alias string) *scanobject {
s.scanobjectDo.DO = *(s.scanobjectDo.As(alias).(*gen.DO))
return s.updateTableName(alias)
}
func (s *scanobject) updateTableName(table string) *scanobject {
s.ALL = field.NewAsterisk(table)
s.ID = field.NewUint(table, "id")
s.CreatedAt = field.NewTime(table, "created_at")
s.UpdatedAt = field.NewTime(table, "updated_at")
s.DeletedAt = field.NewField(table, "deleted_at")
s.fillFieldMap()
return s
}
func (s *scanobject) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := s.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (s *scanobject) fillFieldMap() {
s.fieldMap = make(map[string]field.Expr, 4)
s.fieldMap["id"] = s.ID
s.fieldMap["created_at"] = s.CreatedAt
s.fieldMap["updated_at"] = s.UpdatedAt
s.fieldMap["deleted_at"] = s.DeletedAt
}
func (s scanobject) clone(db *gorm.DB) scanobject {
s.scanobjectDo.ReplaceConnPool(db.Statement.ConnPool)
return s
}
func (s scanobject) replaceDB(db *gorm.DB) scanobject {
s.scanobjectDo.ReplaceDB(db)
return s
}
type scanobjectDo struct{ gen.DO }
type IScanobjectDo interface {
gen.SubQuery
Debug() IScanobjectDo
WithContext(ctx context.Context) IScanobjectDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IScanobjectDo
WriteDB() IScanobjectDo
As(alias string) gen.Dao
Session(config *gorm.Session) IScanobjectDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IScanobjectDo
Not(conds ...gen.Condition) IScanobjectDo
Or(conds ...gen.Condition) IScanobjectDo
Select(conds ...field.Expr) IScanobjectDo
Where(conds ...gen.Condition) IScanobjectDo
Order(conds ...field.Expr) IScanobjectDo
Distinct(cols ...field.Expr) IScanobjectDo
Omit(cols ...field.Expr) IScanobjectDo
Join(table schema.Tabler, on ...field.Expr) IScanobjectDo
LeftJoin(table schema.Tabler, on ...field.Expr) IScanobjectDo
RightJoin(table schema.Tabler, on ...field.Expr) IScanobjectDo
Group(cols ...field.Expr) IScanobjectDo
Having(conds ...gen.Condition) IScanobjectDo
Limit(limit int) IScanobjectDo
Offset(offset int) IScanobjectDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IScanobjectDo
Unscoped() IScanobjectDo
Create(values ...*model.Scanobject) error
CreateInBatches(values []*model.Scanobject, batchSize int) error
Save(values ...*model.Scanobject) error
First() (*model.Scanobject, error)
Take() (*model.Scanobject, error)
Last() (*model.Scanobject, error)
Find() ([]*model.Scanobject, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Scanobject, err error)
FindInBatches(result *[]*model.Scanobject, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.Scanobject) (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) IScanobjectDo
Assign(attrs ...field.AssignExpr) IScanobjectDo
Joins(fields ...field.RelationField) IScanobjectDo
Preload(fields ...field.RelationField) IScanobjectDo
FirstOrInit() (*model.Scanobject, error)
FirstOrCreate() (*model.Scanobject, error)
FindByPage(offset int, limit int) (result []*model.Scanobject, 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) IScanobjectDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (s scanobjectDo) Debug() IScanobjectDo {
return s.withDO(s.DO.Debug())
}
func (s scanobjectDo) WithContext(ctx context.Context) IScanobjectDo {
return s.withDO(s.DO.WithContext(ctx))
}
func (s scanobjectDo) ReadDB() IScanobjectDo {
return s.Clauses(dbresolver.Read)
}
func (s scanobjectDo) WriteDB() IScanobjectDo {
return s.Clauses(dbresolver.Write)
}
func (s scanobjectDo) Session(config *gorm.Session) IScanobjectDo {
return s.withDO(s.DO.Session(config))
}
func (s scanobjectDo) Clauses(conds ...clause.Expression) IScanobjectDo {
return s.withDO(s.DO.Clauses(conds...))
}
func (s scanobjectDo) Returning(value interface{}, columns ...string) IScanobjectDo {
return s.withDO(s.DO.Returning(value, columns...))
}
func (s scanobjectDo) Not(conds ...gen.Condition) IScanobjectDo {
return s.withDO(s.DO.Not(conds...))
}
func (s scanobjectDo) Or(conds ...gen.Condition) IScanobjectDo {
return s.withDO(s.DO.Or(conds...))
}
func (s scanobjectDo) Select(conds ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Select(conds...))
}
func (s scanobjectDo) Where(conds ...gen.Condition) IScanobjectDo {
return s.withDO(s.DO.Where(conds...))
}
func (s scanobjectDo) Order(conds ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Order(conds...))
}
func (s scanobjectDo) Distinct(cols ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Distinct(cols...))
}
func (s scanobjectDo) Omit(cols ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Omit(cols...))
}
func (s scanobjectDo) Join(table schema.Tabler, on ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Join(table, on...))
}
func (s scanobjectDo) LeftJoin(table schema.Tabler, on ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.LeftJoin(table, on...))
}
func (s scanobjectDo) RightJoin(table schema.Tabler, on ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.RightJoin(table, on...))
}
func (s scanobjectDo) Group(cols ...field.Expr) IScanobjectDo {
return s.withDO(s.DO.Group(cols...))
}
func (s scanobjectDo) Having(conds ...gen.Condition) IScanobjectDo {
return s.withDO(s.DO.Having(conds...))
}
func (s scanobjectDo) Limit(limit int) IScanobjectDo {
return s.withDO(s.DO.Limit(limit))
}
func (s scanobjectDo) Offset(offset int) IScanobjectDo {
return s.withDO(s.DO.Offset(offset))
}
func (s scanobjectDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IScanobjectDo {
return s.withDO(s.DO.Scopes(funcs...))
}
func (s scanobjectDo) Unscoped() IScanobjectDo {
return s.withDO(s.DO.Unscoped())
}
func (s scanobjectDo) Create(values ...*model.Scanobject) error {
if len(values) == 0 {
return nil
}
return s.DO.Create(values)
}
func (s scanobjectDo) CreateInBatches(values []*model.Scanobject, batchSize int) error {
return s.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 (s scanobjectDo) Save(values ...*model.Scanobject) error {
if len(values) == 0 {
return nil
}
return s.DO.Save(values)
}
func (s scanobjectDo) First() (*model.Scanobject, error) {
if result, err := s.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.Scanobject), nil
}
}
func (s scanobjectDo) Take() (*model.Scanobject, error) {
if result, err := s.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.Scanobject), nil
}
}
func (s scanobjectDo) Last() (*model.Scanobject, error) {
if result, err := s.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.Scanobject), nil
}
}
func (s scanobjectDo) Find() ([]*model.Scanobject, error) {
result, err := s.DO.Find()
return result.([]*model.Scanobject), err
}
func (s scanobjectDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Scanobject, err error) {
buf := make([]*model.Scanobject, 0, batchSize)
err = s.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 (s scanobjectDo) FindInBatches(result *[]*model.Scanobject, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return s.DO.FindInBatches(result, batchSize, fc)
}
func (s scanobjectDo) Attrs(attrs ...field.AssignExpr) IScanobjectDo {
return s.withDO(s.DO.Attrs(attrs...))
}
func (s scanobjectDo) Assign(attrs ...field.AssignExpr) IScanobjectDo {
return s.withDO(s.DO.Assign(attrs...))
}
func (s scanobjectDo) Joins(fields ...field.RelationField) IScanobjectDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Joins(_f))
}
return &s
}
func (s scanobjectDo) Preload(fields ...field.RelationField) IScanobjectDo {
for _, _f := range fields {
s = *s.withDO(s.DO.Preload(_f))
}
return &s
}
func (s scanobjectDo) FirstOrInit() (*model.Scanobject, error) {
if result, err := s.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.Scanobject), nil
}
}
func (s scanobjectDo) FirstOrCreate() (*model.Scanobject, error) {
if result, err := s.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.Scanobject), nil
}
}
func (s scanobjectDo) FindByPage(offset int, limit int) (result []*model.Scanobject, count int64, err error) {
result, err = s.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 = s.Offset(-1).Limit(-1).Count()
return
}
func (s scanobjectDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = s.Count()
if err != nil {
return
}
err = s.Offset(offset).Limit(limit).Scan(result)
return
}
func (s scanobjectDo) Scan(result interface{}) (err error) {
return s.DO.Scan(result)
}
func (s scanobjectDo) Delete(models ...*model.Scanobject) (result gen.ResultInfo, err error) {
return s.DO.Delete(models)
}
func (s *scanobjectDo) withDO(do gen.Dao) *scanobjectDo {
s.DO = *do.(*gen.DO)
return s
}