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"
|
||||
|
@ -134,11 +135,17 @@ func (e *emote) fillFieldMap() {
|
|||
|
||||
func (e emote) clone(db *gorm.DB) emote {
|
||||
e.emoteDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
e.Metadata.db = db.Session(&gorm.Session{Initialized: true})
|
||||
e.Metadata.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
e.Server.db = db.Session(&gorm.Session{Initialized: true})
|
||||
e.Server.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return e
|
||||
}
|
||||
|
||||
func (e emote) replaceDB(db *gorm.DB) emote {
|
||||
e.emoteDo.ReplaceDB(db)
|
||||
e.Metadata.db = db.Session(&gorm.Session{})
|
||||
e.Server.db = db.Session(&gorm.Session{})
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -175,6 +182,11 @@ func (a emoteBelongsToMetadata) Model(m *models.Emote) *emoteBelongsToMetadataTx
|
|||
return &emoteBelongsToMetadataTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadata) Unscoped() *emoteBelongsToMetadata {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type emoteBelongsToMetadataTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Find() (result *models.MediaMetadata, err error) {
|
||||
|
@ -213,6 +225,11 @@ func (a emoteBelongsToMetadataTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Unscoped() *emoteBelongsToMetadataTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type emoteBelongsToServer struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
@ -256,6 +273,11 @@ func (a emoteBelongsToServer) Model(m *models.Emote) *emoteBelongsToServerTx {
|
|||
return &emoteBelongsToServerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServer) Unscoped() *emoteBelongsToServer {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type emoteBelongsToServerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a emoteBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
|
||||
|
@ -294,6 +316,11 @@ func (a emoteBelongsToServerTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Unscoped() *emoteBelongsToServerTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type emoteDo struct{ gen.DO }
|
||||
|
||||
type IEmoteDo interface {
|
||||
|
@ -351,6 +378,8 @@ type IEmoteDo interface {
|
|||
FirstOrCreate() (*models.Emote, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Emote, 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) IEmoteDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue