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