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