// 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" "stream.api/internal/database/model" ) func newNotification(db *gorm.DB, opts ...gen.DOOption) notification { _notification := notification{} _notification.notificationDo.UseDB(db, opts...) _notification.notificationDo.UseModel(&model.Notification{}) tableName := _notification.notificationDo.TableName() _notification.ALL = field.NewAsterisk(tableName) _notification.ID = field.NewString(tableName, "id") _notification.UserID = field.NewString(tableName, "user_id") _notification.Type = field.NewString(tableName, "type") _notification.Title = field.NewString(tableName, "title") _notification.Message = field.NewString(tableName, "message") _notification.Metadata = field.NewString(tableName, "metadata") _notification.ActionURL = field.NewString(tableName, "action_url") _notification.ActionLabel = field.NewString(tableName, "action_label") _notification.IsRead = field.NewBool(tableName, "is_read") _notification.CreatedAt = field.NewTime(tableName, "created_at") _notification.UpdatedAt = field.NewTime(tableName, "updated_at") _notification.Version = field.NewInt64(tableName, "version") _notification.fillFieldMap() return _notification } type notification struct { notificationDo notificationDo ALL field.Asterisk ID field.String UserID field.String Type field.String Title field.String Message field.String Metadata field.String ActionURL field.String ActionLabel field.String IsRead field.Bool CreatedAt field.Time UpdatedAt field.Time Version field.Int64 fieldMap map[string]field.Expr } func (n notification) Table(newTableName string) *notification { n.notificationDo.UseTable(newTableName) return n.updateTableName(newTableName) } func (n notification) As(alias string) *notification { n.notificationDo.DO = *(n.notificationDo.As(alias).(*gen.DO)) return n.updateTableName(alias) } func (n *notification) updateTableName(table string) *notification { n.ALL = field.NewAsterisk(table) n.ID = field.NewString(table, "id") n.UserID = field.NewString(table, "user_id") n.Type = field.NewString(table, "type") n.Title = field.NewString(table, "title") n.Message = field.NewString(table, "message") n.Metadata = field.NewString(table, "metadata") n.ActionURL = field.NewString(table, "action_url") n.ActionLabel = field.NewString(table, "action_label") n.IsRead = field.NewBool(table, "is_read") n.CreatedAt = field.NewTime(table, "created_at") n.UpdatedAt = field.NewTime(table, "updated_at") n.Version = field.NewInt64(table, "version") n.fillFieldMap() return n } func (n *notification) WithContext(ctx context.Context) INotificationDo { return n.notificationDo.WithContext(ctx) } func (n notification) TableName() string { return n.notificationDo.TableName() } func (n notification) Alias() string { return n.notificationDo.Alias() } func (n notification) Columns(cols ...field.Expr) gen.Columns { return n.notificationDo.Columns(cols...) } func (n *notification) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := n.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (n *notification) fillFieldMap() { n.fieldMap = make(map[string]field.Expr, 12) n.fieldMap["id"] = n.ID n.fieldMap["user_id"] = n.UserID n.fieldMap["type"] = n.Type n.fieldMap["title"] = n.Title n.fieldMap["message"] = n.Message n.fieldMap["metadata"] = n.Metadata n.fieldMap["action_url"] = n.ActionURL n.fieldMap["action_label"] = n.ActionLabel n.fieldMap["is_read"] = n.IsRead n.fieldMap["created_at"] = n.CreatedAt n.fieldMap["updated_at"] = n.UpdatedAt n.fieldMap["version"] = n.Version } func (n notification) clone(db *gorm.DB) notification { n.notificationDo.ReplaceConnPool(db.Statement.ConnPool) return n } func (n notification) replaceDB(db *gorm.DB) notification { n.notificationDo.ReplaceDB(db) return n } type notificationDo struct{ gen.DO } type INotificationDo interface { gen.SubQuery Debug() INotificationDo WithContext(ctx context.Context) INotificationDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() INotificationDo WriteDB() INotificationDo As(alias string) gen.Dao Session(config *gorm.Session) INotificationDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) INotificationDo Not(conds ...gen.Condition) INotificationDo Or(conds ...gen.Condition) INotificationDo Select(conds ...field.Expr) INotificationDo Where(conds ...gen.Condition) INotificationDo Order(conds ...field.Expr) INotificationDo Distinct(cols ...field.Expr) INotificationDo Omit(cols ...field.Expr) INotificationDo Join(table schema.Tabler, on ...field.Expr) INotificationDo LeftJoin(table schema.Tabler, on ...field.Expr) INotificationDo RightJoin(table schema.Tabler, on ...field.Expr) INotificationDo Group(cols ...field.Expr) INotificationDo Having(conds ...gen.Condition) INotificationDo Limit(limit int) INotificationDo Offset(offset int) INotificationDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) INotificationDo Unscoped() INotificationDo Create(values ...*model.Notification) error CreateInBatches(values []*model.Notification, batchSize int) error Save(values ...*model.Notification) error First() (*model.Notification, error) Take() (*model.Notification, error) Last() (*model.Notification, error) Find() ([]*model.Notification, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Notification, err error) FindInBatches(result *[]*model.Notification, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.Notification) (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) INotificationDo Assign(attrs ...field.AssignExpr) INotificationDo Joins(fields ...field.RelationField) INotificationDo Preload(fields ...field.RelationField) INotificationDo FirstOrInit() (*model.Notification, error) FirstOrCreate() (*model.Notification, error) FindByPage(offset int, limit int) (result []*model.Notification, 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) INotificationDo UnderlyingDB() *gorm.DB schema.Tabler } func (n notificationDo) Debug() INotificationDo { return n.withDO(n.DO.Debug()) } func (n notificationDo) WithContext(ctx context.Context) INotificationDo { return n.withDO(n.DO.WithContext(ctx)) } func (n notificationDo) ReadDB() INotificationDo { return n.Clauses(dbresolver.Read) } func (n notificationDo) WriteDB() INotificationDo { return n.Clauses(dbresolver.Write) } func (n notificationDo) Session(config *gorm.Session) INotificationDo { return n.withDO(n.DO.Session(config)) } func (n notificationDo) Clauses(conds ...clause.Expression) INotificationDo { return n.withDO(n.DO.Clauses(conds...)) } func (n notificationDo) Returning(value interface{}, columns ...string) INotificationDo { return n.withDO(n.DO.Returning(value, columns...)) } func (n notificationDo) Not(conds ...gen.Condition) INotificationDo { return n.withDO(n.DO.Not(conds...)) } func (n notificationDo) Or(conds ...gen.Condition) INotificationDo { return n.withDO(n.DO.Or(conds...)) } func (n notificationDo) Select(conds ...field.Expr) INotificationDo { return n.withDO(n.DO.Select(conds...)) } func (n notificationDo) Where(conds ...gen.Condition) INotificationDo { return n.withDO(n.DO.Where(conds...)) } func (n notificationDo) Order(conds ...field.Expr) INotificationDo { return n.withDO(n.DO.Order(conds...)) } func (n notificationDo) Distinct(cols ...field.Expr) INotificationDo { return n.withDO(n.DO.Distinct(cols...)) } func (n notificationDo) Omit(cols ...field.Expr) INotificationDo { return n.withDO(n.DO.Omit(cols...)) } func (n notificationDo) Join(table schema.Tabler, on ...field.Expr) INotificationDo { return n.withDO(n.DO.Join(table, on...)) } func (n notificationDo) LeftJoin(table schema.Tabler, on ...field.Expr) INotificationDo { return n.withDO(n.DO.LeftJoin(table, on...)) } func (n notificationDo) RightJoin(table schema.Tabler, on ...field.Expr) INotificationDo { return n.withDO(n.DO.RightJoin(table, on...)) } func (n notificationDo) Group(cols ...field.Expr) INotificationDo { return n.withDO(n.DO.Group(cols...)) } func (n notificationDo) Having(conds ...gen.Condition) INotificationDo { return n.withDO(n.DO.Having(conds...)) } func (n notificationDo) Limit(limit int) INotificationDo { return n.withDO(n.DO.Limit(limit)) } func (n notificationDo) Offset(offset int) INotificationDo { return n.withDO(n.DO.Offset(offset)) } func (n notificationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INotificationDo { return n.withDO(n.DO.Scopes(funcs...)) } func (n notificationDo) Unscoped() INotificationDo { return n.withDO(n.DO.Unscoped()) } func (n notificationDo) Create(values ...*model.Notification) error { if len(values) == 0 { return nil } return n.DO.Create(values) } func (n notificationDo) CreateInBatches(values []*model.Notification, batchSize int) error { return n.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 (n notificationDo) Save(values ...*model.Notification) error { if len(values) == 0 { return nil } return n.DO.Save(values) } func (n notificationDo) First() (*model.Notification, error) { if result, err := n.DO.First(); err != nil { return nil, err } else { return result.(*model.Notification), nil } } func (n notificationDo) Take() (*model.Notification, error) { if result, err := n.DO.Take(); err != nil { return nil, err } else { return result.(*model.Notification), nil } } func (n notificationDo) Last() (*model.Notification, error) { if result, err := n.DO.Last(); err != nil { return nil, err } else { return result.(*model.Notification), nil } } func (n notificationDo) Find() ([]*model.Notification, error) { result, err := n.DO.Find() return result.([]*model.Notification), err } func (n notificationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Notification, err error) { buf := make([]*model.Notification, 0, batchSize) err = n.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 (n notificationDo) FindInBatches(result *[]*model.Notification, batchSize int, fc func(tx gen.Dao, batch int) error) error { return n.DO.FindInBatches(result, batchSize, fc) } func (n notificationDo) Attrs(attrs ...field.AssignExpr) INotificationDo { return n.withDO(n.DO.Attrs(attrs...)) } func (n notificationDo) Assign(attrs ...field.AssignExpr) INotificationDo { return n.withDO(n.DO.Assign(attrs...)) } func (n notificationDo) Joins(fields ...field.RelationField) INotificationDo { for _, _f := range fields { n = *n.withDO(n.DO.Joins(_f)) } return &n } func (n notificationDo) Preload(fields ...field.RelationField) INotificationDo { for _, _f := range fields { n = *n.withDO(n.DO.Preload(_f)) } return &n } func (n notificationDo) FirstOrInit() (*model.Notification, error) { if result, err := n.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.Notification), nil } } func (n notificationDo) FirstOrCreate() (*model.Notification, error) { if result, err := n.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.Notification), nil } } func (n notificationDo) FindByPage(offset int, limit int) (result []*model.Notification, count int64, err error) { result, err = n.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 = n.Offset(-1).Limit(-1).Count() return } func (n notificationDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = n.Count() if err != nil { return } err = n.Offset(offset).Limit(limit).Scan(result) return } func (n notificationDo) Scan(result interface{}) (err error) { return n.DO.Scan(result) } func (n notificationDo) Delete(models ...*model.Notification) (result gen.ResultInfo, err error) { return n.DO.Delete(models) } func (n *notificationDo) withDO(do gen.Dao) *notificationDo { n.DO = *do.(*gen.DO) return n }