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"
|
||||
|
@ -315,6 +316,19 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
|||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToBoost.fillFieldMap()
|
||||
|
@ -379,11 +393,17 @@ func (n *noteToBoost) fillFieldMap() {
|
|||
|
||||
func (n noteToBoost) clone(db *gorm.DB) noteToBoost {
|
||||
n.noteToBoostDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
n.User.db = db.Session(&gorm.Session{Initialized: true})
|
||||
n.User.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
n.Note.db = db.Session(&gorm.Session{Initialized: true})
|
||||
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToBoost) replaceDB(db *gorm.DB) noteToBoost {
|
||||
n.noteToBoostDo.ReplaceDB(db)
|
||||
n.User.db = db.Session(&gorm.Session{})
|
||||
n.Note.db = db.Session(&gorm.Session{})
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -496,6 +516,11 @@ func (a noteToBoostBelongsToUser) Model(m *models.NoteToBoost) *noteToBoostBelon
|
|||
return ¬eToBoostBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUser) Unscoped() *noteToBoostBelongsToUser {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
|
@ -534,6 +559,11 @@ func (a noteToBoostBelongsToUserTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Unscoped() *noteToBoostBelongsToUserTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -584,6 +614,12 @@ type noteToBoostBelongsToNote struct {
|
|||
field.RelationField
|
||||
}
|
||||
}
|
||||
Edits struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNote) Where(conds ...field.Expr) *noteToBoostBelongsToNote {
|
||||
|
@ -613,6 +649,11 @@ func (a noteToBoostBelongsToNote) Model(m *models.NoteToBoost) *noteToBoostBelon
|
|||
return ¬eToBoostBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNote) Unscoped() *noteToBoostBelongsToNote {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
|
@ -651,6 +692,11 @@ func (a noteToBoostBelongsToNoteTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Unscoped() *noteToBoostBelongsToNoteTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToBoostDo struct{ gen.DO }
|
||||
|
||||
type INoteToBoostDo interface {
|
||||
|
@ -708,6 +754,8 @@ type INoteToBoostDo interface {
|
|||
FirstOrCreate() (*models.NoteToBoost, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToBoost, 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) INoteToBoostDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue