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