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"
|
||||
|
@ -153,11 +154,17 @@ func (r *remoteServer) fillFieldMap() {
|
|||
|
||||
func (r remoteServer) clone(db *gorm.DB) remoteServer {
|
||||
r.remoteServerDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
r.Metadata.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Metadata.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
r.Icon.db = db.Session(&gorm.Session{Initialized: true})
|
||||
r.Icon.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return r
|
||||
}
|
||||
|
||||
func (r remoteServer) replaceDB(db *gorm.DB) remoteServer {
|
||||
r.remoteServerDo.ReplaceDB(db)
|
||||
r.Metadata.db = db.Session(&gorm.Session{})
|
||||
r.Icon.db = db.Session(&gorm.Session{})
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -204,6 +211,11 @@ func (a remoteServerHasManyMetadata) Model(m *models.RemoteServer) *remoteServer
|
|||
return &remoteServerHasManyMetadataTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a remoteServerHasManyMetadata) Unscoped() *remoteServerHasManyMetadata {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type remoteServerHasManyMetadataTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a remoteServerHasManyMetadataTx) Find() (result []*models.RemoteServerMetadata, err error) {
|
||||
|
@ -242,6 +254,11 @@ func (a remoteServerHasManyMetadataTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a remoteServerHasManyMetadataTx) Unscoped() *remoteServerHasManyMetadataTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type remoteServerBelongsToIcon struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -275,6 +292,11 @@ func (a remoteServerBelongsToIcon) Model(m *models.RemoteServer) *remoteServerBe
|
|||
return &remoteServerBelongsToIconTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a remoteServerBelongsToIcon) Unscoped() *remoteServerBelongsToIcon {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type remoteServerBelongsToIconTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a remoteServerBelongsToIconTx) Find() (result *models.MediaMetadata, err error) {
|
||||
|
@ -313,6 +335,11 @@ func (a remoteServerBelongsToIconTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a remoteServerBelongsToIconTx) Unscoped() *remoteServerBelongsToIconTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type remoteServerDo struct{ gen.DO }
|
||||
|
||||
type IRemoteServerDo interface {
|
||||
|
@ -370,6 +397,8 @@ type IRemoteServerDo interface {
|
|||
FirstOrCreate() (*models.RemoteServer, error)
|
||||
FindByPage(offset int, limit int) (result []*models.RemoteServer, 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) IRemoteServerDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue