// 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 dbgen import ( "context" "git.mstar.dev/mstar/linstrom/storage-new/models" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" ) func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing { _noteToPing := noteToPing{} _noteToPing.noteToPingDo.UseDB(db, opts...) _noteToPing.noteToPingDo.UseModel(&models.NoteToPing{}) tableName := _noteToPing.noteToPingDo.TableName() _noteToPing.ALL = field.NewAsterisk(tableName) _noteToPing.ID = field.NewUint64(tableName, "id") _noteToPing.NoteId = field.NewString(tableName, "note_id") _noteToPing.PingTargetId = field.NewString(tableName, "ping_target_id") _noteToPing.Note = noteToPingBelongsToNote{ db: db.Session(&gorm.Session{}), RelationField: field.NewRelation("Note", "models.Note"), Creator: struct { field.RelationField Server struct { field.RelationField Icon struct { field.RelationField } } Icon struct { field.RelationField } Background struct { field.RelationField } Banner struct { field.RelationField } RemoteInfo struct { field.RelationField User struct { field.RelationField } } InfoFields struct { field.RelationField User struct { field.RelationField } } BeingTypes struct { field.RelationField User struct { field.RelationField } } Tags struct { field.RelationField User struct { field.RelationField } } Relations struct { field.RelationField User struct { field.RelationField } TargetUser struct { field.RelationField } } Pronouns struct { field.RelationField User struct { field.RelationField } } Roles struct { field.RelationField User struct { field.RelationField } Role struct { field.RelationField } } AuthMethods struct { field.RelationField User struct { field.RelationField } } }{ RelationField: field.NewRelation("Note.Creator", "models.User"), Server: struct { field.RelationField Icon struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"), Icon: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"), }, }, Icon: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Icon", "models.MediaMetadata"), }, Background: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Background", "models.MediaMetadata"), }, Banner: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Banner", "models.MediaMetadata"), }, RemoteInfo: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.RemoteInfo", "models.UserRemoteLinks"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.RemoteInfo.User", "models.User"), }, }, InfoFields: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.InfoFields", "models.UserInfoField"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.InfoFields.User", "models.User"), }, }, BeingTypes: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.BeingTypes", "models.UserToBeing"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.BeingTypes.User", "models.User"), }, }, Tags: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.Tags", "models.UserToTag"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Tags.User", "models.User"), }, }, Relations: struct { field.RelationField User struct { field.RelationField } TargetUser struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.Relations", "models.UserToUserRelation"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Relations.User", "models.User"), }, TargetUser: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Relations.TargetUser", "models.User"), }, }, Pronouns: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.Pronouns", "models.UserToPronoun"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Pronouns.User", "models.User"), }, }, Roles: struct { field.RelationField User struct { field.RelationField } Role struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.Roles", "models.UserToRole"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Roles.User", "models.User"), }, Role: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.Roles.Role", "models.Role"), }, }, AuthMethods: struct { field.RelationField User struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Creator.AuthMethods", "models.UserAuthMethod"), User: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Creator.AuthMethods.User", "models.User"), }, }, }, AttachmentRelations: struct { field.RelationField Note struct { field.RelationField } Attachment struct { field.RelationField } }{ RelationField: field.NewRelation("Note.AttachmentRelations", "models.NoteToAttachment"), Note: struct { field.RelationField }{ RelationField: field.NewRelation("Note.AttachmentRelations.Note", "models.Note"), }, Attachment: struct { field.RelationField }{ RelationField: field.NewRelation("Note.AttachmentRelations.Attachment", "models.MediaMetadata"), }, }, EmoteRelations: struct { field.RelationField Note struct { field.RelationField } Emote struct { field.RelationField Metadata struct { field.RelationField } Server struct { field.RelationField } } }{ RelationField: field.NewRelation("Note.EmoteRelations", "models.NoteToEmote"), Note: struct { field.RelationField }{ RelationField: field.NewRelation("Note.EmoteRelations.Note", "models.Note"), }, Emote: struct { field.RelationField Metadata struct { field.RelationField } Server struct { field.RelationField } }{ RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"), Metadata: struct { field.RelationField }{ RelationField: field.NewRelation("Note.EmoteRelations.Emote.Metadata", "models.MediaMetadata"), }, Server: struct { field.RelationField }{ RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"), }, }, }, PingRelations: struct { field.RelationField Note struct { field.RelationField } PingTarget struct { field.RelationField } }{ RelationField: field.NewRelation("Note.PingRelations", "models.NoteToPing"), Note: struct { field.RelationField }{ RelationField: field.NewRelation("Note.PingRelations.Note", "models.Note"), }, PingTarget: struct { field.RelationField }{ RelationField: field.NewRelation("Note.PingRelations.PingTarget", "models.User"), }, }, Tags: struct { field.RelationField Note struct { field.RelationField } }{ RelationField: field.NewRelation("Note.Tags", "models.NoteTag"), Note: struct { field.RelationField }{ RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), }, }, } _noteToPing.PingTarget = noteToPingBelongsToPingTarget{ db: db.Session(&gorm.Session{}), RelationField: field.NewRelation("PingTarget", "models.User"), } _noteToPing.fillFieldMap() return _noteToPing } type noteToPing struct { noteToPingDo ALL field.Asterisk ID field.Uint64 NoteId field.String PingTargetId field.String Note noteToPingBelongsToNote PingTarget noteToPingBelongsToPingTarget fieldMap map[string]field.Expr } func (n noteToPing) Table(newTableName string) *noteToPing { n.noteToPingDo.UseTable(newTableName) return n.updateTableName(newTableName) } func (n noteToPing) As(alias string) *noteToPing { n.noteToPingDo.DO = *(n.noteToPingDo.As(alias).(*gen.DO)) return n.updateTableName(alias) } func (n *noteToPing) updateTableName(table string) *noteToPing { n.ALL = field.NewAsterisk(table) n.ID = field.NewUint64(table, "id") n.NoteId = field.NewString(table, "note_id") n.PingTargetId = field.NewString(table, "ping_target_id") n.fillFieldMap() return n } func (n *noteToPing) 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 *noteToPing) fillFieldMap() { n.fieldMap = make(map[string]field.Expr, 5) n.fieldMap["id"] = n.ID n.fieldMap["note_id"] = n.NoteId n.fieldMap["ping_target_id"] = n.PingTargetId } func (n noteToPing) clone(db *gorm.DB) noteToPing { n.noteToPingDo.ReplaceConnPool(db.Statement.ConnPool) return n } func (n noteToPing) replaceDB(db *gorm.DB) noteToPing { n.noteToPingDo.ReplaceDB(db) return n } type noteToPingBelongsToNote struct { db *gorm.DB field.RelationField Creator struct { field.RelationField Server struct { field.RelationField Icon struct { field.RelationField } } Icon struct { field.RelationField } Background struct { field.RelationField } Banner struct { field.RelationField } RemoteInfo struct { field.RelationField User struct { field.RelationField } } InfoFields struct { field.RelationField User struct { field.RelationField } } BeingTypes struct { field.RelationField User struct { field.RelationField } } Tags struct { field.RelationField User struct { field.RelationField } } Relations struct { field.RelationField User struct { field.RelationField } TargetUser struct { field.RelationField } } Pronouns struct { field.RelationField User struct { field.RelationField } } Roles struct { field.RelationField User struct { field.RelationField } Role struct { field.RelationField } } AuthMethods struct { field.RelationField User struct { field.RelationField } } } AttachmentRelations struct { field.RelationField Note struct { field.RelationField } Attachment struct { field.RelationField } } EmoteRelations struct { field.RelationField Note struct { field.RelationField } Emote struct { field.RelationField Metadata struct { field.RelationField } Server struct { field.RelationField } } } PingRelations struct { field.RelationField Note struct { field.RelationField } PingTarget struct { field.RelationField } } Tags struct { field.RelationField Note struct { field.RelationField } } } func (a noteToPingBelongsToNote) Where(conds ...field.Expr) *noteToPingBelongsToNote { 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 noteToPingBelongsToNote) WithContext(ctx context.Context) *noteToPingBelongsToNote { a.db = a.db.WithContext(ctx) return &a } func (a noteToPingBelongsToNote) Session(session *gorm.Session) *noteToPingBelongsToNote { a.db = a.db.Session(session) return &a } func (a noteToPingBelongsToNote) Model(m *models.NoteToPing) *noteToPingBelongsToNoteTx { return ¬eToPingBelongsToNoteTx{a.db.Model(m).Association(a.Name())} } type noteToPingBelongsToNoteTx struct{ tx *gorm.Association } func (a noteToPingBelongsToNoteTx) Find() (result *models.Note, err error) { return result, a.tx.Find(&result) } func (a noteToPingBelongsToNoteTx) Append(values ...*models.Note) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Append(targetValues...) } func (a noteToPingBelongsToNoteTx) Replace(values ...*models.Note) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Replace(targetValues...) } func (a noteToPingBelongsToNoteTx) Delete(values ...*models.Note) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Delete(targetValues...) } func (a noteToPingBelongsToNoteTx) Clear() error { return a.tx.Clear() } func (a noteToPingBelongsToNoteTx) Count() int64 { return a.tx.Count() } type noteToPingBelongsToPingTarget struct { db *gorm.DB field.RelationField } func (a noteToPingBelongsToPingTarget) Where(conds ...field.Expr) *noteToPingBelongsToPingTarget { 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 noteToPingBelongsToPingTarget) WithContext(ctx context.Context) *noteToPingBelongsToPingTarget { a.db = a.db.WithContext(ctx) return &a } func (a noteToPingBelongsToPingTarget) Session(session *gorm.Session) *noteToPingBelongsToPingTarget { a.db = a.db.Session(session) return &a } func (a noteToPingBelongsToPingTarget) Model(m *models.NoteToPing) *noteToPingBelongsToPingTargetTx { return ¬eToPingBelongsToPingTargetTx{a.db.Model(m).Association(a.Name())} } type noteToPingBelongsToPingTargetTx struct{ tx *gorm.Association } func (a noteToPingBelongsToPingTargetTx) Find() (result *models.User, err error) { return result, a.tx.Find(&result) } func (a noteToPingBelongsToPingTargetTx) Append(values ...*models.User) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Append(targetValues...) } func (a noteToPingBelongsToPingTargetTx) Replace(values ...*models.User) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Replace(targetValues...) } func (a noteToPingBelongsToPingTargetTx) Delete(values ...*models.User) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Delete(targetValues...) } func (a noteToPingBelongsToPingTargetTx) Clear() error { return a.tx.Clear() } func (a noteToPingBelongsToPingTargetTx) Count() int64 { return a.tx.Count() } type noteToPingDo struct{ gen.DO } type INoteToPingDo interface { gen.SubQuery Debug() INoteToPingDo WithContext(ctx context.Context) INoteToPingDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() INoteToPingDo WriteDB() INoteToPingDo As(alias string) gen.Dao Session(config *gorm.Session) INoteToPingDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) INoteToPingDo Not(conds ...gen.Condition) INoteToPingDo Or(conds ...gen.Condition) INoteToPingDo Select(conds ...field.Expr) INoteToPingDo Where(conds ...gen.Condition) INoteToPingDo Order(conds ...field.Expr) INoteToPingDo Distinct(cols ...field.Expr) INoteToPingDo Omit(cols ...field.Expr) INoteToPingDo Join(table schema.Tabler, on ...field.Expr) INoteToPingDo LeftJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo RightJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo Group(cols ...field.Expr) INoteToPingDo Having(conds ...gen.Condition) INoteToPingDo Limit(limit int) INoteToPingDo Offset(offset int) INoteToPingDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToPingDo Unscoped() INoteToPingDo Create(values ...*models.NoteToPing) error CreateInBatches(values []*models.NoteToPing, batchSize int) error Save(values ...*models.NoteToPing) error First() (*models.NoteToPing, error) Take() (*models.NoteToPing, error) Last() (*models.NoteToPing, error) Find() ([]*models.NoteToPing, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToPing, err error) FindInBatches(result *[]*models.NoteToPing, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*models.NoteToPing) (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) INoteToPingDo Assign(attrs ...field.AssignExpr) INoteToPingDo Joins(fields ...field.RelationField) INoteToPingDo Preload(fields ...field.RelationField) INoteToPingDo FirstOrInit() (*models.NoteToPing, error) FirstOrCreate() (*models.NoteToPing, error) FindByPage(offset int, limit int) (result []*models.NoteToPing, 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) INoteToPingDo UnderlyingDB() *gorm.DB schema.Tabler } func (n noteToPingDo) Debug() INoteToPingDo { return n.withDO(n.DO.Debug()) } func (n noteToPingDo) WithContext(ctx context.Context) INoteToPingDo { return n.withDO(n.DO.WithContext(ctx)) } func (n noteToPingDo) ReadDB() INoteToPingDo { return n.Clauses(dbresolver.Read) } func (n noteToPingDo) WriteDB() INoteToPingDo { return n.Clauses(dbresolver.Write) } func (n noteToPingDo) Session(config *gorm.Session) INoteToPingDo { return n.withDO(n.DO.Session(config)) } func (n noteToPingDo) Clauses(conds ...clause.Expression) INoteToPingDo { return n.withDO(n.DO.Clauses(conds...)) } func (n noteToPingDo) Returning(value interface{}, columns ...string) INoteToPingDo { return n.withDO(n.DO.Returning(value, columns...)) } func (n noteToPingDo) Not(conds ...gen.Condition) INoteToPingDo { return n.withDO(n.DO.Not(conds...)) } func (n noteToPingDo) Or(conds ...gen.Condition) INoteToPingDo { return n.withDO(n.DO.Or(conds...)) } func (n noteToPingDo) Select(conds ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Select(conds...)) } func (n noteToPingDo) Where(conds ...gen.Condition) INoteToPingDo { return n.withDO(n.DO.Where(conds...)) } func (n noteToPingDo) Order(conds ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Order(conds...)) } func (n noteToPingDo) Distinct(cols ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Distinct(cols...)) } func (n noteToPingDo) Omit(cols ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Omit(cols...)) } func (n noteToPingDo) Join(table schema.Tabler, on ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Join(table, on...)) } func (n noteToPingDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo { return n.withDO(n.DO.LeftJoin(table, on...)) } func (n noteToPingDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo { return n.withDO(n.DO.RightJoin(table, on...)) } func (n noteToPingDo) Group(cols ...field.Expr) INoteToPingDo { return n.withDO(n.DO.Group(cols...)) } func (n noteToPingDo) Having(conds ...gen.Condition) INoteToPingDo { return n.withDO(n.DO.Having(conds...)) } func (n noteToPingDo) Limit(limit int) INoteToPingDo { return n.withDO(n.DO.Limit(limit)) } func (n noteToPingDo) Offset(offset int) INoteToPingDo { return n.withDO(n.DO.Offset(offset)) } func (n noteToPingDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToPingDo { return n.withDO(n.DO.Scopes(funcs...)) } func (n noteToPingDo) Unscoped() INoteToPingDo { return n.withDO(n.DO.Unscoped()) } func (n noteToPingDo) Create(values ...*models.NoteToPing) error { if len(values) == 0 { return nil } return n.DO.Create(values) } func (n noteToPingDo) CreateInBatches(values []*models.NoteToPing, 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 noteToPingDo) Save(values ...*models.NoteToPing) error { if len(values) == 0 { return nil } return n.DO.Save(values) } func (n noteToPingDo) First() (*models.NoteToPing, error) { if result, err := n.DO.First(); err != nil { return nil, err } else { return result.(*models.NoteToPing), nil } } func (n noteToPingDo) Take() (*models.NoteToPing, error) { if result, err := n.DO.Take(); err != nil { return nil, err } else { return result.(*models.NoteToPing), nil } } func (n noteToPingDo) Last() (*models.NoteToPing, error) { if result, err := n.DO.Last(); err != nil { return nil, err } else { return result.(*models.NoteToPing), nil } } func (n noteToPingDo) Find() ([]*models.NoteToPing, error) { result, err := n.DO.Find() return result.([]*models.NoteToPing), err } func (n noteToPingDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToPing, err error) { buf := make([]*models.NoteToPing, 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 noteToPingDo) FindInBatches(result *[]*models.NoteToPing, batchSize int, fc func(tx gen.Dao, batch int) error) error { return n.DO.FindInBatches(result, batchSize, fc) } func (n noteToPingDo) Attrs(attrs ...field.AssignExpr) INoteToPingDo { return n.withDO(n.DO.Attrs(attrs...)) } func (n noteToPingDo) Assign(attrs ...field.AssignExpr) INoteToPingDo { return n.withDO(n.DO.Assign(attrs...)) } func (n noteToPingDo) Joins(fields ...field.RelationField) INoteToPingDo { for _, _f := range fields { n = *n.withDO(n.DO.Joins(_f)) } return &n } func (n noteToPingDo) Preload(fields ...field.RelationField) INoteToPingDo { for _, _f := range fields { n = *n.withDO(n.DO.Preload(_f)) } return &n } func (n noteToPingDo) FirstOrInit() (*models.NoteToPing, error) { if result, err := n.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*models.NoteToPing), nil } } func (n noteToPingDo) FirstOrCreate() (*models.NoteToPing, error) { if result, err := n.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*models.NoteToPing), nil } } func (n noteToPingDo) FindByPage(offset int, limit int) (result []*models.NoteToPing, 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 noteToPingDo) 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 noteToPingDo) Scan(result interface{}) (err error) { return n.DO.Scan(result) } func (n noteToPingDo) Delete(models ...*models.NoteToPing) (result gen.ResultInfo, err error) { return n.DO.Delete(models) } func (n *noteToPingDo) withDO(do gen.Dao) *noteToPingDo { n.DO = *do.(*gen.DO) return n }