This commit is contained in:
parent
d32818af09
commit
cfa0566c6d
39 changed files with 2276 additions and 183 deletions
|
@ -6,6 +6,7 @@ package dbgen
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
"gorm.io/gorm"
|
||||
|
@ -387,6 +388,19 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"),
|
||||
},
|
||||
},
|
||||
Edits: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Edits", "models.NoteEdit"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Edits.Note", "models.Note"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_reaction.Reactor = reactionBelongsToReactor{
|
||||
|
@ -474,11 +488,20 @@ func (r *reaction) fillFieldMap() {
|
|||
|
||||
func (r reaction) clone(db *gorm.DB) reaction {
|
||||
r.reactionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
r.Note.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Note.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
r.Reactor.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Reactor.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
r.Emote.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Emote.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return r
|
||||
}
|
||||
|
||||
func (r reaction) replaceDB(db *gorm.DB) reaction {
|
||||
r.reactionDo.ReplaceDB(db)
|
||||
r.Note.db = db.Session(&gorm.Session{})
|
||||
r.Reactor.db = db.Session(&gorm.Session{})
|
||||
r.Emote.db = db.Session(&gorm.Session{})
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -607,6 +630,12 @@ type reactionBelongsToNote struct {
|
|||
field.RelationField
|
||||
}
|
||||
}
|
||||
Edits struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNote) Where(conds ...field.Expr) *reactionBelongsToNote {
|
||||
|
@ -636,6 +665,11 @@ func (a reactionBelongsToNote) Model(m *models.Reaction) *reactionBelongsToNoteT
|
|||
return &reactionBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNote) Unscoped() *reactionBelongsToNote {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
|
@ -674,6 +708,11 @@ func (a reactionBelongsToNoteTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNoteTx) Unscoped() *reactionBelongsToNoteTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionBelongsToReactor struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -707,6 +746,11 @@ func (a reactionBelongsToReactor) Model(m *models.Reaction) *reactionBelongsToRe
|
|||
return &reactionBelongsToReactorTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactor) Unscoped() *reactionBelongsToReactor {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionBelongsToReactorTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToReactorTx) Find() (result *models.User, err error) {
|
||||
|
@ -745,6 +789,11 @@ func (a reactionBelongsToReactorTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactorTx) Unscoped() *reactionBelongsToReactorTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionBelongsToEmote struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -778,6 +827,11 @@ func (a reactionBelongsToEmote) Model(m *models.Reaction) *reactionBelongsToEmot
|
|||
return &reactionBelongsToEmoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmote) Unscoped() *reactionBelongsToEmote {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionBelongsToEmoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Find() (result *models.Emote, err error) {
|
||||
|
@ -816,6 +870,11 @@ func (a reactionBelongsToEmoteTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Unscoped() *reactionBelongsToEmoteTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type reactionDo struct{ gen.DO }
|
||||
|
||||
type IReactionDo interface {
|
||||
|
@ -873,6 +932,8 @@ type IReactionDo interface {
|
|||
FirstOrCreate() (*models.Reaction, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Reaction, 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) IReactionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue