// 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" "github.com/TremblingV5/DouTok/applications/comment/infra/model" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" ) func newCommentCount(db *gorm.DB, opts ...gen.DOOption) commentCount { _commentCount := commentCount{} _commentCount.commentCountDo.UseDB(db, opts...) _commentCount.commentCountDo.UseModel(&model.CommentCount{}) tableName := _commentCount.commentCountDo.TableName() _commentCount.ALL = field.NewAsterisk(tableName) _commentCount.Id = field.NewInt64(tableName, "id") _commentCount.Number = field.NewInt64(tableName, "number") _commentCount.CreatedAt = field.NewTime(tableName, "created_at") _commentCount.UpdatedAt = field.NewTime(tableName, "updated_at") _commentCount.fillFieldMap() return _commentCount } type commentCount struct { commentCountDo ALL field.Asterisk Id field.Int64 Number field.Int64 CreatedAt field.Time UpdatedAt field.Time fieldMap map[string]field.Expr } func (c commentCount) Table(newTableName string) *commentCount { c.commentCountDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c commentCount) As(alias string) *commentCount { c.commentCountDo.DO = *(c.commentCountDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *commentCount) updateTableName(table string) *commentCount { c.ALL = field.NewAsterisk(table) c.Id = field.NewInt64(table, "id") c.Number = field.NewInt64(table, "number") c.CreatedAt = field.NewTime(table, "created_at") c.UpdatedAt = field.NewTime(table, "updated_at") c.fillFieldMap() return c } func (c *commentCount) 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 *commentCount) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 4) c.fieldMap["id"] = c.Id c.fieldMap["number"] = c.Number c.fieldMap["created_at"] = c.CreatedAt c.fieldMap["updated_at"] = c.UpdatedAt } func (c commentCount) clone(db *gorm.DB) commentCount { c.commentCountDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c commentCount) replaceDB(db *gorm.DB) commentCount { c.commentCountDo.ReplaceDB(db) return c } type commentCountDo struct{ gen.DO } type ICommentCountDo interface { gen.SubQuery Debug() ICommentCountDo WithContext(ctx context.Context) ICommentCountDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() ICommentCountDo WriteDB() ICommentCountDo As(alias string) gen.Dao Session(config *gorm.Session) ICommentCountDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) ICommentCountDo Not(conds ...gen.Condition) ICommentCountDo Or(conds ...gen.Condition) ICommentCountDo Select(conds ...field.Expr) ICommentCountDo Where(conds ...gen.Condition) ICommentCountDo Order(conds ...field.Expr) ICommentCountDo Distinct(cols ...field.Expr) ICommentCountDo Omit(cols ...field.Expr) ICommentCountDo Join(table schema.Tabler, on ...field.Expr) ICommentCountDo LeftJoin(table schema.Tabler, on ...field.Expr) ICommentCountDo RightJoin(table schema.Tabler, on ...field.Expr) ICommentCountDo Group(cols ...field.Expr) ICommentCountDo Having(conds ...gen.Condition) ICommentCountDo Limit(limit int) ICommentCountDo Offset(offset int) ICommentCountDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) ICommentCountDo Unscoped() ICommentCountDo Create(values ...*model.CommentCount) error CreateInBatches(values []*model.CommentCount, batchSize int) error Save(values ...*model.CommentCount) error First() (*model.CommentCount, error) Take() (*model.CommentCount, error) Last() (*model.CommentCount, error) Find() ([]*model.CommentCount, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.CommentCount, err error) FindInBatches(result *[]*model.CommentCount, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.CommentCount) (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) ICommentCountDo Assign(attrs ...field.AssignExpr) ICommentCountDo Joins(fields ...field.RelationField) ICommentCountDo Preload(fields ...field.RelationField) ICommentCountDo FirstOrInit() (*model.CommentCount, error) FirstOrCreate() (*model.CommentCount, error) FindByPage(offset int, limit int) (result []*model.CommentCount, 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) ICommentCountDo UnderlyingDB() *gorm.DB schema.Tabler } func (c commentCountDo) Debug() ICommentCountDo { return c.withDO(c.DO.Debug()) } func (c commentCountDo) WithContext(ctx context.Context) ICommentCountDo { return c.withDO(c.DO.WithContext(ctx)) } func (c commentCountDo) ReadDB() ICommentCountDo { return c.Clauses(dbresolver.Read) } func (c commentCountDo) WriteDB() ICommentCountDo { return c.Clauses(dbresolver.Write) } func (c commentCountDo) Session(config *gorm.Session) ICommentCountDo { return c.withDO(c.DO.Session(config)) } func (c commentCountDo) Clauses(conds ...clause.Expression) ICommentCountDo { return c.withDO(c.DO.Clauses(conds...)) } func (c commentCountDo) Returning(value interface{}, columns ...string) ICommentCountDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c commentCountDo) Not(conds ...gen.Condition) ICommentCountDo { return c.withDO(c.DO.Not(conds...)) } func (c commentCountDo) Or(conds ...gen.Condition) ICommentCountDo { return c.withDO(c.DO.Or(conds...)) } func (c commentCountDo) Select(conds ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Select(conds...)) } func (c commentCountDo) Where(conds ...gen.Condition) ICommentCountDo { return c.withDO(c.DO.Where(conds...)) } func (c commentCountDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) ICommentCountDo { return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (c commentCountDo) Order(conds ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Order(conds...)) } func (c commentCountDo) Distinct(cols ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Distinct(cols...)) } func (c commentCountDo) Omit(cols ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Omit(cols...)) } func (c commentCountDo) Join(table schema.Tabler, on ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Join(table, on...)) } func (c commentCountDo) LeftJoin(table schema.Tabler, on ...field.Expr) ICommentCountDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c commentCountDo) RightJoin(table schema.Tabler, on ...field.Expr) ICommentCountDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c commentCountDo) Group(cols ...field.Expr) ICommentCountDo { return c.withDO(c.DO.Group(cols...)) } func (c commentCountDo) Having(conds ...gen.Condition) ICommentCountDo { return c.withDO(c.DO.Having(conds...)) } func (c commentCountDo) Limit(limit int) ICommentCountDo { return c.withDO(c.DO.Limit(limit)) } func (c commentCountDo) Offset(offset int) ICommentCountDo { return c.withDO(c.DO.Offset(offset)) } func (c commentCountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ICommentCountDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c commentCountDo) Unscoped() ICommentCountDo { return c.withDO(c.DO.Unscoped()) } func (c commentCountDo) Create(values ...*model.CommentCount) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c commentCountDo) CreateInBatches(values []*model.CommentCount, 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 commentCountDo) Save(values ...*model.CommentCount) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c commentCountDo) First() (*model.CommentCount, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.CommentCount), nil } } func (c commentCountDo) Take() (*model.CommentCount, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.CommentCount), nil } } func (c commentCountDo) Last() (*model.CommentCount, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.CommentCount), nil } } func (c commentCountDo) Find() ([]*model.CommentCount, error) { result, err := c.DO.Find() return result.([]*model.CommentCount), err } func (c commentCountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.CommentCount, err error) { buf := make([]*model.CommentCount, 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 commentCountDo) FindInBatches(result *[]*model.CommentCount, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c commentCountDo) Attrs(attrs ...field.AssignExpr) ICommentCountDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c commentCountDo) Assign(attrs ...field.AssignExpr) ICommentCountDo { return c.withDO(c.DO.Assign(attrs...)) } func (c commentCountDo) Joins(fields ...field.RelationField) ICommentCountDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c commentCountDo) Preload(fields ...field.RelationField) ICommentCountDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c commentCountDo) FirstOrInit() (*model.CommentCount, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.CommentCount), nil } } func (c commentCountDo) FirstOrCreate() (*model.CommentCount, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.CommentCount), nil } } func (c commentCountDo) FindByPage(offset int, limit int) (result []*model.CommentCount, 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 commentCountDo) 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 commentCountDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c commentCountDo) Delete(models ...*model.CommentCount) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *commentCountDo) withDO(do gen.Dao) *commentCountDo { c.DO = *do.(*gen.DO) return c }