zdravko/internal/models/query/healthchecks.gen.go

403 lines
12 KiB
Go
Raw Normal View History

2024-02-11 10:56:21 +00:00
// 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/database"
)
func newHealthcheck(db *gorm.DB, opts ...gen.DOOption) healthcheck {
_healthcheck := healthcheck{}
_healthcheck.healthcheckDo.UseDB(db, opts...)
_healthcheck.healthcheckDo.UseModel(&database.Healthcheck{})
tableName := _healthcheck.healthcheckDo.TableName()
_healthcheck.ALL = field.NewAsterisk(tableName)
_healthcheck.ID = field.NewUint(tableName, "id")
_healthcheck.Name = field.NewString(tableName, "name")
_healthcheck.Status = field.NewString(tableName, "status")
_healthcheck.UptimePercentage = field.NewFloat64(tableName, "uptime_percentage")
_healthcheck.fillFieldMap()
return _healthcheck
}
type healthcheck struct {
healthcheckDo healthcheckDo
ALL field.Asterisk
ID field.Uint
Name field.String
Status field.String
UptimePercentage field.Float64
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.Name = field.NewString(table, "name")
h.Status = field.NewString(table, "status")
h.UptimePercentage = field.NewFloat64(table, "uptime_percentage")
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, 4)
h.fieldMap["id"] = h.ID
h.fieldMap["name"] = h.Name
h.fieldMap["status"] = h.Status
h.fieldMap["uptime_percentage"] = h.UptimePercentage
}
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 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 ...*database.Healthcheck) error
CreateInBatches(values []*database.Healthcheck, batchSize int) error
Save(values ...*database.Healthcheck) error
First() (*database.Healthcheck, error)
Take() (*database.Healthcheck, error)
Last() (*database.Healthcheck, error)
Find() ([]*database.Healthcheck, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*database.Healthcheck, err error)
FindInBatches(result *[]*database.Healthcheck, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*database.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() (*database.Healthcheck, error)
FirstOrCreate() (*database.Healthcheck, error)
FindByPage(offset int, limit int) (result []*database.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 ...*database.Healthcheck) error {
if len(values) == 0 {
return nil
}
return h.DO.Create(values)
}
func (h healthcheckDo) CreateInBatches(values []*database.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 ...*database.Healthcheck) error {
if len(values) == 0 {
return nil
}
return h.DO.Save(values)
}
func (h healthcheckDo) First() (*database.Healthcheck, error) {
if result, err := h.DO.First(); err != nil {
return nil, err
} else {
return result.(*database.Healthcheck), nil
}
}
func (h healthcheckDo) Take() (*database.Healthcheck, error) {
if result, err := h.DO.Take(); err != nil {
return nil, err
} else {
return result.(*database.Healthcheck), nil
}
}
func (h healthcheckDo) Last() (*database.Healthcheck, error) {
if result, err := h.DO.Last(); err != nil {
return nil, err
} else {
return result.(*database.Healthcheck), nil
}
}
func (h healthcheckDo) Find() ([]*database.Healthcheck, error) {
result, err := h.DO.Find()
return result.([]*database.Healthcheck), err
}
func (h healthcheckDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*database.Healthcheck, err error) {
buf := make([]*database.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 *[]*database.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() (*database.Healthcheck, error) {
if result, err := h.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*database.Healthcheck), nil
}
}
func (h healthcheckDo) FirstOrCreate() (*database.Healthcheck, error) {
if result, err := h.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*database.Healthcheck), nil
}
}
func (h healthcheckDo) FindByPage(offset int, limit int) (result []*database.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 ...*database.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
}