// 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 newHealthcheck(db *gorm.DB, opts ...gen.DOOption) healthcheck { _healthcheck := healthcheck{} _healthcheck.healthcheckDo.UseDB(db, opts...) _healthcheck.healthcheckDo.UseModel(&models.Healthcheck{}) tableName := _healthcheck.healthcheckDo.TableName() _healthcheck.ALL = field.NewAsterisk(tableName) _healthcheck.ID = field.NewUint(tableName, "id") _healthcheck.CreatedAt = field.NewTime(tableName, "created_at") _healthcheck.UpdatedAt = field.NewTime(tableName, "updated_at") _healthcheck.DeletedAt = field.NewField(tableName, "deleted_at") _healthcheck.Slug = field.NewString(tableName, "slug") _healthcheck.Name = field.NewString(tableName, "name") _healthcheck.Schedule = field.NewString(tableName, "schedule") _healthcheck.WorkerGroups = field.NewField(tableName, "worker_groups") _healthcheck.Script = field.NewString(tableName, "script") _healthcheck.History = healthcheckHasManyHistory{ db: db.Session(&gorm.Session{}), RelationField: field.NewRelation("History", "models.HealthcheckHistory"), } _healthcheck.fillFieldMap() return _healthcheck } type healthcheck struct { healthcheckDo healthcheckDo ALL field.Asterisk ID field.Uint CreatedAt field.Time UpdatedAt field.Time DeletedAt field.Field Slug field.String Name field.String Schedule field.String WorkerGroups field.Field Script field.String History healthcheckHasManyHistory fieldMap map[string]field.Expr } func (h healthcheck) Table(newTableName string) *healthcheck { h.healthcheckDo.UseTable(newTableName) return h.updateTableName(newTableName) } func (h healthcheck) As(alias string) *healthcheck { h.healthcheckDo.DO = *(h.healthcheckDo.As(alias).(*gen.DO)) return h.updateTableName(alias) } func (h *healthcheck) updateTableName(table string) *healthcheck { h.ALL = field.NewAsterisk(table) h.ID = field.NewUint(table, "id") h.CreatedAt = field.NewTime(table, "created_at") h.UpdatedAt = field.NewTime(table, "updated_at") h.DeletedAt = field.NewField(table, "deleted_at") h.Slug = field.NewString(table, "slug") h.Name = field.NewString(table, "name") h.Schedule = field.NewString(table, "schedule") h.WorkerGroups = field.NewField(table, "worker_groups") h.Script = field.NewString(table, "script") h.fillFieldMap() return h } func (h *healthcheck) WithContext(ctx context.Context) IHealthcheckDo { return h.healthcheckDo.WithContext(ctx) } func (h healthcheck) TableName() string { return h.healthcheckDo.TableName() } func (h healthcheck) Alias() string { return h.healthcheckDo.Alias() } func (h healthcheck) Columns(cols ...field.Expr) gen.Columns { return h.healthcheckDo.Columns(cols...) } func (h *healthcheck) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := h.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (h *healthcheck) fillFieldMap() { h.fieldMap = make(map[string]field.Expr, 10) h.fieldMap["id"] = h.ID h.fieldMap["created_at"] = h.CreatedAt h.fieldMap["updated_at"] = h.UpdatedAt h.fieldMap["deleted_at"] = h.DeletedAt h.fieldMap["slug"] = h.Slug h.fieldMap["name"] = h.Name h.fieldMap["schedule"] = h.Schedule h.fieldMap["worker_groups"] = h.WorkerGroups h.fieldMap["script"] = h.Script } func (h healthcheck) clone(db *gorm.DB) healthcheck { h.healthcheckDo.ReplaceConnPool(db.Statement.ConnPool) return h } func (h healthcheck) replaceDB(db *gorm.DB) healthcheck { h.healthcheckDo.ReplaceDB(db) return h } type healthcheckHasManyHistory struct { db *gorm.DB field.RelationField } func (a healthcheckHasManyHistory) Where(conds ...field.Expr) *healthcheckHasManyHistory { if len(conds) == 0 { return &a } exprs := make([]clause.Expression, 0, len(conds)) for _, cond := range conds { exprs = append(exprs, cond.BeCond().(clause.Expression)) } a.db = a.db.Clauses(clause.Where{Exprs: exprs}) return &a } func (a healthcheckHasManyHistory) WithContext(ctx context.Context) *healthcheckHasManyHistory { a.db = a.db.WithContext(ctx) return &a } func (a healthcheckHasManyHistory) Session(session *gorm.Session) *healthcheckHasManyHistory { a.db = a.db.Session(session) return &a } func (a healthcheckHasManyHistory) Model(m *models.Healthcheck) *healthcheckHasManyHistoryTx { return &healthcheckHasManyHistoryTx{a.db.Model(m).Association(a.Name())} } type healthcheckHasManyHistoryTx struct{ tx *gorm.Association } func (a healthcheckHasManyHistoryTx) Find() (result []*models.HealthcheckHistory, err error) { return result, a.tx.Find(&result) } func (a healthcheckHasManyHistoryTx) Append(values ...*models.HealthcheckHistory) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Append(targetValues...) } func (a healthcheckHasManyHistoryTx) Replace(values ...*models.HealthcheckHistory) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Replace(targetValues...) } func (a healthcheckHasManyHistoryTx) Delete(values ...*models.HealthcheckHistory) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Delete(targetValues...) } func (a healthcheckHasManyHistoryTx) Clear() error { return a.tx.Clear() } func (a healthcheckHasManyHistoryTx) Count() int64 { return a.tx.Count() } type healthcheckDo struct{ gen.DO } type IHealthcheckDo interface { gen.SubQuery Debug() IHealthcheckDo WithContext(ctx context.Context) IHealthcheckDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IHealthcheckDo WriteDB() IHealthcheckDo As(alias string) gen.Dao Session(config *gorm.Session) IHealthcheckDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IHealthcheckDo Not(conds ...gen.Condition) IHealthcheckDo Or(conds ...gen.Condition) IHealthcheckDo Select(conds ...field.Expr) IHealthcheckDo Where(conds ...gen.Condition) IHealthcheckDo Order(conds ...field.Expr) IHealthcheckDo Distinct(cols ...field.Expr) IHealthcheckDo Omit(cols ...field.Expr) IHealthcheckDo Join(table schema.Tabler, on ...field.Expr) IHealthcheckDo LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckDo RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckDo Group(cols ...field.Expr) IHealthcheckDo Having(conds ...gen.Condition) IHealthcheckDo Limit(limit int) IHealthcheckDo Offset(offset int) IHealthcheckDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckDo Unscoped() IHealthcheckDo Create(values ...*models.Healthcheck) error CreateInBatches(values []*models.Healthcheck, batchSize int) error Save(values ...*models.Healthcheck) error First() (*models.Healthcheck, error) Take() (*models.Healthcheck, error) Last() (*models.Healthcheck, error) Find() ([]*models.Healthcheck, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Healthcheck, err error) FindInBatches(result *[]*models.Healthcheck, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*models.Healthcheck) (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) IHealthcheckDo Assign(attrs ...field.AssignExpr) IHealthcheckDo Joins(fields ...field.RelationField) IHealthcheckDo Preload(fields ...field.RelationField) IHealthcheckDo FirstOrInit() (*models.Healthcheck, error) FirstOrCreate() (*models.Healthcheck, error) FindByPage(offset int, limit int) (result []*models.Healthcheck, 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) IHealthcheckDo UnderlyingDB() *gorm.DB schema.Tabler } func (h healthcheckDo) Debug() IHealthcheckDo { return h.withDO(h.DO.Debug()) } func (h healthcheckDo) WithContext(ctx context.Context) IHealthcheckDo { return h.withDO(h.DO.WithContext(ctx)) } func (h healthcheckDo) ReadDB() IHealthcheckDo { return h.Clauses(dbresolver.Read) } func (h healthcheckDo) WriteDB() IHealthcheckDo { return h.Clauses(dbresolver.Write) } func (h healthcheckDo) Session(config *gorm.Session) IHealthcheckDo { return h.withDO(h.DO.Session(config)) } func (h healthcheckDo) Clauses(conds ...clause.Expression) IHealthcheckDo { return h.withDO(h.DO.Clauses(conds...)) } func (h healthcheckDo) Returning(value interface{}, columns ...string) IHealthcheckDo { return h.withDO(h.DO.Returning(value, columns...)) } func (h healthcheckDo) Not(conds ...gen.Condition) IHealthcheckDo { return h.withDO(h.DO.Not(conds...)) } func (h healthcheckDo) Or(conds ...gen.Condition) IHealthcheckDo { return h.withDO(h.DO.Or(conds...)) } func (h healthcheckDo) Select(conds ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Select(conds...)) } func (h healthcheckDo) Where(conds ...gen.Condition) IHealthcheckDo { return h.withDO(h.DO.Where(conds...)) } func (h healthcheckDo) Order(conds ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Order(conds...)) } func (h healthcheckDo) Distinct(cols ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Distinct(cols...)) } func (h healthcheckDo) Omit(cols ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Omit(cols...)) } func (h healthcheckDo) Join(table schema.Tabler, on ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Join(table, on...)) } func (h healthcheckDo) LeftJoin(table schema.Tabler, on ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.LeftJoin(table, on...)) } func (h healthcheckDo) RightJoin(table schema.Tabler, on ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.RightJoin(table, on...)) } func (h healthcheckDo) Group(cols ...field.Expr) IHealthcheckDo { return h.withDO(h.DO.Group(cols...)) } func (h healthcheckDo) Having(conds ...gen.Condition) IHealthcheckDo { return h.withDO(h.DO.Having(conds...)) } func (h healthcheckDo) Limit(limit int) IHealthcheckDo { return h.withDO(h.DO.Limit(limit)) } func (h healthcheckDo) Offset(offset int) IHealthcheckDo { return h.withDO(h.DO.Offset(offset)) } func (h healthcheckDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IHealthcheckDo { return h.withDO(h.DO.Scopes(funcs...)) } func (h healthcheckDo) Unscoped() IHealthcheckDo { return h.withDO(h.DO.Unscoped()) } func (h healthcheckDo) Create(values ...*models.Healthcheck) error { if len(values) == 0 { return nil } return h.DO.Create(values) } func (h healthcheckDo) CreateInBatches(values []*models.Healthcheck, batchSize int) error { return h.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 (h healthcheckDo) Save(values ...*models.Healthcheck) error { if len(values) == 0 { return nil } return h.DO.Save(values) } func (h healthcheckDo) First() (*models.Healthcheck, error) { if result, err := h.DO.First(); err != nil { return nil, err } else { return result.(*models.Healthcheck), nil } } func (h healthcheckDo) Take() (*models.Healthcheck, error) { if result, err := h.DO.Take(); err != nil { return nil, err } else { return result.(*models.Healthcheck), nil } } func (h healthcheckDo) Last() (*models.Healthcheck, error) { if result, err := h.DO.Last(); err != nil { return nil, err } else { return result.(*models.Healthcheck), nil } } func (h healthcheckDo) Find() ([]*models.Healthcheck, error) { result, err := h.DO.Find() return result.([]*models.Healthcheck), err } func (h healthcheckDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Healthcheck, err error) { buf := make([]*models.Healthcheck, 0, batchSize) err = h.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 (h healthcheckDo) FindInBatches(result *[]*models.Healthcheck, batchSize int, fc func(tx gen.Dao, batch int) error) error { return h.DO.FindInBatches(result, batchSize, fc) } func (h healthcheckDo) Attrs(attrs ...field.AssignExpr) IHealthcheckDo { return h.withDO(h.DO.Attrs(attrs...)) } func (h healthcheckDo) Assign(attrs ...field.AssignExpr) IHealthcheckDo { return h.withDO(h.DO.Assign(attrs...)) } func (h healthcheckDo) Joins(fields ...field.RelationField) IHealthcheckDo { for _, _f := range fields { h = *h.withDO(h.DO.Joins(_f)) } return &h } func (h healthcheckDo) Preload(fields ...field.RelationField) IHealthcheckDo { for _, _f := range fields { h = *h.withDO(h.DO.Preload(_f)) } return &h } func (h healthcheckDo) FirstOrInit() (*models.Healthcheck, error) { if result, err := h.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*models.Healthcheck), nil } } func (h healthcheckDo) FirstOrCreate() (*models.Healthcheck, error) { if result, err := h.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*models.Healthcheck), nil } } func (h healthcheckDo) FindByPage(offset int, limit int) (result []*models.Healthcheck, count int64, err error) { result, err = h.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 = h.Offset(-1).Limit(-1).Count() return } func (h healthcheckDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = h.Count() if err != nil { return } err = h.Offset(offset).Limit(limit).Scan(result) return } func (h healthcheckDo) Scan(result interface{}) (err error) { return h.DO.Scan(result) } func (h healthcheckDo) Delete(models ...*models.Healthcheck) (result gen.ResultInfo, err error) { return h.DO.Delete(models) } func (h *healthcheckDo) withDO(do gen.Dao) *healthcheckDo { h.DO = *do.(*gen.DO) return h }