Work on AS activities and objects
All checks were successful
/ docker (push) Successful in 4m15s

This commit is contained in:
Melody Becker 2025-04-29 21:35:58 +02:00
parent d32818af09
commit cfa0566c6d
Signed by: mstar
SSH key fingerprint: SHA256:vkXfS9FG2pVNVfvDrzd1VW9n8VJzqqdKQGljxxX8uK8
39 changed files with 2276 additions and 183 deletions

View file

@ -135,6 +135,7 @@ type ConfigExperimental struct {
// They are shorter than the main method used (uuid v4) but should still provide enough // They are shorter than the main method used (uuid v4) but should still provide enough
// uniqueness such that collisions are not to be expected. // uniqueness such that collisions are not to be expected.
// Changing this option will only affect new ID generations, not update existing ones // Changing this option will only affect new ID generations, not update existing ones
// As of now, even that doesn't work due to implementation details
UseCuid2Ids bool `toml:"use_cuid2_ids"` UseCuid2Ids bool `toml:"use_cuid2_ids"`
} }

View file

@ -1,178 +0,0 @@
package config
import (
"fmt"
"os"
"github.com/BurntSushi/toml"
"github.com/rs/zerolog/log"
"git.mstar.dev/mstar/goutils/other"
)
type ConfigSSL struct {
HandleSSL bool `toml:"handle_ssl"` // Whether Linstrom should handle SSL encryption itself
// If Linstrom is to handle SSL, whether it should use LetsEncrypt for certificates
UseLetsEncrypt *bool `toml:"use_lets_encrypt"`
// Path to the certificate if Linstrom is to handle SSL while not using LetsEncrypt
CertificateFile *string `toml:"certificate_file"`
// Mail adress to use in case of using LetsEncrypt
AdminMail *string `toml:"admin_mail"`
}
type ConfigGeneral struct {
Protocol string `toml:"protocol"` // The protocol with which to access the server publicly (http/https)
// The subdomain under which the server lives (example: "linstrom" if the full domain is linstrom.example.com)
Subdomain *string `toml:"subdomain"`
// The root domain under which the server lives (example: "example.com" if the full domain is linstrom.example.com)
Domain string `toml:"domain"`
// The port on which the server runs on
PrivatePort int `toml:"private_port"`
// The port under which the public can reach the server (useful if running behind a reverse proxy)
PublicPort *int `toml:"public_port"`
// File to write structured logs to (structured being formatted as json)
// If not set, Linstrom won't write structured logs
StructuredLogFile *string
}
type ConfigWebAuthn struct {
DisplayName string `toml:"display_name"`
HashingSecret string `toml:"hashing_secret"`
}
type ConfigAdmin struct {
// Name of the server's root admin account
Username string `toml:"username"`
// A one time password used to verify account access to the root admin
// after a server has been created and before the account could be linked to a passkey
FirstTimeSetupOTP string `toml:"first_time_setup_otp"`
}
type ConfigStorage struct {
// Url to the database to use
// If DbIsPostgres is either not set or false, the url is expected to be a path to a sqlite file
// Otherwise, it's expected to be an url to a postgres server
DatabaseUrl string `toml:"database_url"`
// Whether the target of the database url is a postgres server
DbIsPostgres *bool `toml:"db_is_postgres,omitempty"`
// Url to redis server. If empty, no redis is used
RedisUrl *string `toml:"redis_url,omitempty"`
// The maximum size of the in-memory cache in bytes
MaxInMemoryCacheSize int64 `toml:"max_in_memory_cache_size"`
}
type Config struct {
General ConfigGeneral `toml:"general"`
SSL ConfigSSL `toml:"ssl"`
Admin ConfigAdmin `toml:"admin"`
Webauthn ConfigWebAuthn `toml:"webauthn"`
Storage ConfigStorage `toml:"storage"`
}
var GlobalConfig Config
var defaultConfig Config = Config{
General: ConfigGeneral{
Protocol: "http",
Subdomain: nil,
Domain: "localhost",
PrivatePort: 8080,
PublicPort: nil,
},
SSL: ConfigSSL{
HandleSSL: false,
UseLetsEncrypt: nil,
CertificateFile: nil,
AdminMail: nil,
},
Admin: ConfigAdmin{
Username: "server-admin",
FirstTimeSetupOTP: "Example otp password",
},
Webauthn: ConfigWebAuthn{
DisplayName: "Linstrom",
HashingSecret: "some super secure secret that should never be changed or else password storage breaks",
},
Storage: ConfigStorage{
DatabaseUrl: "db.sqlite",
DbIsPostgres: other.IntoPointer(false),
RedisUrl: nil,
MaxInMemoryCacheSize: 1e6, // 1 Megabyte
},
}
func (gc *ConfigGeneral) GetFullDomain() string {
if gc.Subdomain != nil {
return *gc.Subdomain + gc.Domain
}
return gc.Domain
}
func (gc *ConfigGeneral) GetFullPublicUrl() string {
str := gc.Protocol + gc.GetFullDomain()
if gc.PublicPort != nil {
str += fmt.Sprint(*gc.PublicPort)
} else {
str += fmt.Sprint(gc.PrivatePort)
}
return str
}
func WriteDefaultConfig(toFile string) error {
log.Trace().Caller().Send()
log.Info().Str("config-file", toFile).Msg("Writing default config to file")
file, err := os.Create(toFile)
if err != nil {
log.Error().
Err(err).
Str("config-file", toFile).
Msg("Failed to create file for default config")
return err
}
defer file.Close()
data, err := toml.Marshal(&defaultConfig)
if err != nil {
log.Error().Err(err).Msg("Failed to marshal default config to toml")
return err
}
_, err = file.Write(data)
if err != nil {
log.Error().Err(err).Str("config-file", toFile).Msg("Failed to write default config")
return err
}
log.Info().Str("config-file", toFile).Msg("Wrote default config")
return nil
}
func ReadAndWriteToGlobal(fileName string) error {
log.Trace().Caller().Send()
log.Debug().Str("config-file", fileName).Msg("Attempting to read config file")
data, err := os.ReadFile(fileName)
if err != nil {
log.Warn().
Str("config-file", fileName).
Err(err).
Msg("Failed to read config file, attempting to write default config")
err = WriteDefaultConfig(fileName)
if err != nil {
log.Error().
Err(err).
Str("config-file", fileName).
Msg("Failed to create default config file")
return err
}
GlobalConfig = defaultConfig
return nil
}
config := Config{}
log.Debug().Str("config-file", fileName).Msg("Read config file, attempting to unmarshal")
err = toml.Unmarshal(data, &config)
if err != nil {
log.Error().Err(err).Bytes("config-data-raw", data).Msg("Failed to unmarshal config file")
return err
}
GlobalConfig = config
log.Info().Str("config-file", fileName).Msg("Read and applied config file")
return nil
}

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"strings" "strings"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
@ -264,11 +265,14 @@ func (a *accessToken) fillFieldMap() {
func (a accessToken) clone(db *gorm.DB) accessToken { func (a accessToken) clone(db *gorm.DB) accessToken {
a.accessTokenDo.ReplaceConnPool(db.Statement.ConnPool) a.accessTokenDo.ReplaceConnPool(db.Statement.ConnPool)
a.User.db = db.Session(&gorm.Session{Initialized: true})
a.User.db.Statement.ConnPool = db.Statement.ConnPool
return a return a
} }
func (a accessToken) replaceDB(db *gorm.DB) accessToken { func (a accessToken) replaceDB(db *gorm.DB) accessToken {
a.accessTokenDo.ReplaceDB(db) a.accessTokenDo.ReplaceDB(db)
a.User.db = db.Session(&gorm.Session{})
return a return a
} }
@ -381,6 +385,11 @@ func (a accessTokenBelongsToUser) Model(m *models.AccessToken) *accessTokenBelon
return &accessTokenBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &accessTokenBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a accessTokenBelongsToUser) Unscoped() *accessTokenBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type accessTokenBelongsToUserTx struct{ tx *gorm.Association } type accessTokenBelongsToUserTx struct{ tx *gorm.Association }
func (a accessTokenBelongsToUserTx) Find() (result *models.User, err error) { func (a accessTokenBelongsToUserTx) Find() (result *models.User, err error) {
@ -419,6 +428,11 @@ func (a accessTokenBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a accessTokenBelongsToUserTx) Unscoped() *accessTokenBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type accessTokenDo struct{ gen.DO } type accessTokenDo struct{ gen.DO }
type IAccessTokenDo interface { type IAccessTokenDo interface {
@ -476,6 +490,8 @@ type IAccessTokenDo interface {
FirstOrCreate() (*models.AccessToken, error) FirstOrCreate() (*models.AccessToken, error)
FindByPage(offset int, limit int) (result []*models.AccessToken, count int64, err error) FindByPage(offset int, limit int) (result []*models.AccessToken, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAccessTokenDo Returning(value interface{}, columns ...string) IAccessTokenDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -134,11 +135,17 @@ func (e *emote) fillFieldMap() {
func (e emote) clone(db *gorm.DB) emote { func (e emote) clone(db *gorm.DB) emote {
e.emoteDo.ReplaceConnPool(db.Statement.ConnPool) 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 return e
} }
func (e emote) replaceDB(db *gorm.DB) emote { func (e emote) replaceDB(db *gorm.DB) emote {
e.emoteDo.ReplaceDB(db) e.emoteDo.ReplaceDB(db)
e.Metadata.db = db.Session(&gorm.Session{})
e.Server.db = db.Session(&gorm.Session{})
return e return e
} }
@ -175,6 +182,11 @@ func (a emoteBelongsToMetadata) Model(m *models.Emote) *emoteBelongsToMetadataTx
return &emoteBelongsToMetadataTx{a.db.Model(m).Association(a.Name())} 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 } type emoteBelongsToMetadataTx struct{ tx *gorm.Association }
func (a emoteBelongsToMetadataTx) Find() (result *models.MediaMetadata, err error) { func (a emoteBelongsToMetadataTx) Find() (result *models.MediaMetadata, err error) {
@ -213,6 +225,11 @@ func (a emoteBelongsToMetadataTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a emoteBelongsToMetadataTx) Unscoped() *emoteBelongsToMetadataTx {
a.tx = a.tx.Unscoped()
return &a
}
type emoteBelongsToServer struct { type emoteBelongsToServer struct {
db *gorm.DB db *gorm.DB
@ -256,6 +273,11 @@ func (a emoteBelongsToServer) Model(m *models.Emote) *emoteBelongsToServerTx {
return &emoteBelongsToServerTx{a.db.Model(m).Association(a.Name())} 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 } type emoteBelongsToServerTx struct{ tx *gorm.Association }
func (a emoteBelongsToServerTx) Find() (result *models.RemoteServer, err error) { func (a emoteBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
@ -294,6 +316,11 @@ func (a emoteBelongsToServerTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a emoteBelongsToServerTx) Unscoped() *emoteBelongsToServerTx {
a.tx = a.tx.Unscoped()
return &a
}
type emoteDo struct{ gen.DO } type emoteDo struct{ gen.DO }
type IEmoteDo interface { type IEmoteDo interface {
@ -351,6 +378,8 @@ type IEmoteDo interface {
FirstOrCreate() (*models.Emote, error) FirstOrCreate() (*models.Emote, error)
FindByPage(offset int, limit int) (result []*models.Emote, count int64, err error) FindByPage(offset int, limit int) (result []*models.Emote, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IEmoteDo Returning(value interface{}, columns ...string) IEmoteDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -279,11 +280,14 @@ func (f *feed) fillFieldMap() {
func (f feed) clone(db *gorm.DB) feed { func (f feed) clone(db *gorm.DB) feed {
f.feedDo.ReplaceConnPool(db.Statement.ConnPool) f.feedDo.ReplaceConnPool(db.Statement.ConnPool)
f.Owner.db = db.Session(&gorm.Session{Initialized: true})
f.Owner.db.Statement.ConnPool = db.Statement.ConnPool
return f return f
} }
func (f feed) replaceDB(db *gorm.DB) feed { func (f feed) replaceDB(db *gorm.DB) feed {
f.feedDo.ReplaceDB(db) f.feedDo.ReplaceDB(db)
f.Owner.db = db.Session(&gorm.Session{})
return f return f
} }
@ -396,6 +400,11 @@ func (a feedBelongsToOwner) Model(m *models.Feed) *feedBelongsToOwnerTx {
return &feedBelongsToOwnerTx{a.db.Model(m).Association(a.Name())} return &feedBelongsToOwnerTx{a.db.Model(m).Association(a.Name())}
} }
func (a feedBelongsToOwner) Unscoped() *feedBelongsToOwner {
a.db = a.db.Unscoped()
return &a
}
type feedBelongsToOwnerTx struct{ tx *gorm.Association } type feedBelongsToOwnerTx struct{ tx *gorm.Association }
func (a feedBelongsToOwnerTx) Find() (result *models.User, err error) { func (a feedBelongsToOwnerTx) Find() (result *models.User, err error) {
@ -434,6 +443,11 @@ func (a feedBelongsToOwnerTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a feedBelongsToOwnerTx) Unscoped() *feedBelongsToOwnerTx {
a.tx = a.tx.Unscoped()
return &a
}
type feedDo struct{ gen.DO } type feedDo struct{ gen.DO }
type IFeedDo interface { type IFeedDo interface {
@ -491,6 +505,8 @@ type IFeedDo interface {
FirstOrCreate() (*models.Feed, error) FirstOrCreate() (*models.Feed, error)
FindByPage(offset int, limit int) (result []*models.Feed, count int64, err error) FindByPage(offset int, limit int) (result []*models.Feed, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IFeedDo Returning(value interface{}, columns ...string) IFeedDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -23,6 +23,7 @@ var (
LoginProcessToken *loginProcessToken LoginProcessToken *loginProcessToken
MediaMetadata *mediaMetadata MediaMetadata *mediaMetadata
Note *note Note *note
NoteEdit *noteEdit
NoteTag *noteTag NoteTag *noteTag
NoteToAttachment *noteToAttachment NoteToAttachment *noteToAttachment
NoteToBoost *noteToBoost NoteToBoost *noteToBoost
@ -53,6 +54,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
LoginProcessToken = &Q.LoginProcessToken LoginProcessToken = &Q.LoginProcessToken
MediaMetadata = &Q.MediaMetadata MediaMetadata = &Q.MediaMetadata
Note = &Q.Note Note = &Q.Note
NoteEdit = &Q.NoteEdit
NoteTag = &Q.NoteTag NoteTag = &Q.NoteTag
NoteToAttachment = &Q.NoteToAttachment NoteToAttachment = &Q.NoteToAttachment
NoteToBoost = &Q.NoteToBoost NoteToBoost = &Q.NoteToBoost
@ -84,6 +86,7 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
LoginProcessToken: newLoginProcessToken(db, opts...), LoginProcessToken: newLoginProcessToken(db, opts...),
MediaMetadata: newMediaMetadata(db, opts...), MediaMetadata: newMediaMetadata(db, opts...),
Note: newNote(db, opts...), Note: newNote(db, opts...),
NoteEdit: newNoteEdit(db, opts...),
NoteTag: newNoteTag(db, opts...), NoteTag: newNoteTag(db, opts...),
NoteToAttachment: newNoteToAttachment(db, opts...), NoteToAttachment: newNoteToAttachment(db, opts...),
NoteToBoost: newNoteToBoost(db, opts...), NoteToBoost: newNoteToBoost(db, opts...),
@ -116,6 +119,7 @@ type Query struct {
LoginProcessToken loginProcessToken LoginProcessToken loginProcessToken
MediaMetadata mediaMetadata MediaMetadata mediaMetadata
Note note Note note
NoteEdit noteEdit
NoteTag noteTag NoteTag noteTag
NoteToAttachment noteToAttachment NoteToAttachment noteToAttachment
NoteToBoost noteToBoost NoteToBoost noteToBoost
@ -149,6 +153,7 @@ func (q *Query) clone(db *gorm.DB) *Query {
LoginProcessToken: q.LoginProcessToken.clone(db), LoginProcessToken: q.LoginProcessToken.clone(db),
MediaMetadata: q.MediaMetadata.clone(db), MediaMetadata: q.MediaMetadata.clone(db),
Note: q.Note.clone(db), Note: q.Note.clone(db),
NoteEdit: q.NoteEdit.clone(db),
NoteTag: q.NoteTag.clone(db), NoteTag: q.NoteTag.clone(db),
NoteToAttachment: q.NoteToAttachment.clone(db), NoteToAttachment: q.NoteToAttachment.clone(db),
NoteToBoost: q.NoteToBoost.clone(db), NoteToBoost: q.NoteToBoost.clone(db),
@ -189,6 +194,7 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
LoginProcessToken: q.LoginProcessToken.replaceDB(db), LoginProcessToken: q.LoginProcessToken.replaceDB(db),
MediaMetadata: q.MediaMetadata.replaceDB(db), MediaMetadata: q.MediaMetadata.replaceDB(db),
Note: q.Note.replaceDB(db), Note: q.Note.replaceDB(db),
NoteEdit: q.NoteEdit.replaceDB(db),
NoteTag: q.NoteTag.replaceDB(db), NoteTag: q.NoteTag.replaceDB(db),
NoteToAttachment: q.NoteToAttachment.replaceDB(db), NoteToAttachment: q.NoteToAttachment.replaceDB(db),
NoteToBoost: q.NoteToBoost.replaceDB(db), NoteToBoost: q.NoteToBoost.replaceDB(db),
@ -219,6 +225,7 @@ type queryCtx struct {
LoginProcessToken ILoginProcessTokenDo LoginProcessToken ILoginProcessTokenDo
MediaMetadata IMediaMetadataDo MediaMetadata IMediaMetadataDo
Note INoteDo Note INoteDo
NoteEdit INoteEditDo
NoteTag INoteTagDo NoteTag INoteTagDo
NoteToAttachment INoteToAttachmentDo NoteToAttachment INoteToAttachmentDo
NoteToBoost INoteToBoostDo NoteToBoost INoteToBoostDo
@ -249,6 +256,7 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
LoginProcessToken: q.LoginProcessToken.WithContext(ctx), LoginProcessToken: q.LoginProcessToken.WithContext(ctx),
MediaMetadata: q.MediaMetadata.WithContext(ctx), MediaMetadata: q.MediaMetadata.WithContext(ctx),
Note: q.Note.WithContext(ctx), Note: q.Note.WithContext(ctx),
NoteEdit: q.NoteEdit.WithContext(ctx),
NoteTag: q.NoteTag.WithContext(ctx), NoteTag: q.NoteTag.WithContext(ctx),
NoteToAttachment: q.NoteToAttachment.WithContext(ctx), NoteToAttachment: q.NoteToAttachment.WithContext(ctx),
NoteToBoost: q.NoteToBoost.WithContext(ctx), NoteToBoost: q.NoteToBoost.WithContext(ctx),

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -267,11 +268,14 @@ func (l *loginProcessToken) fillFieldMap() {
func (l loginProcessToken) clone(db *gorm.DB) loginProcessToken { func (l loginProcessToken) clone(db *gorm.DB) loginProcessToken {
l.loginProcessTokenDo.ReplaceConnPool(db.Statement.ConnPool) l.loginProcessTokenDo.ReplaceConnPool(db.Statement.ConnPool)
l.User.db = db.Session(&gorm.Session{Initialized: true})
l.User.db.Statement.ConnPool = db.Statement.ConnPool
return l return l
} }
func (l loginProcessToken) replaceDB(db *gorm.DB) loginProcessToken { func (l loginProcessToken) replaceDB(db *gorm.DB) loginProcessToken {
l.loginProcessTokenDo.ReplaceDB(db) l.loginProcessTokenDo.ReplaceDB(db)
l.User.db = db.Session(&gorm.Session{})
return l return l
} }
@ -384,6 +388,11 @@ func (a loginProcessTokenBelongsToUser) Model(m *models.LoginProcessToken) *logi
return &loginProcessTokenBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &loginProcessTokenBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a loginProcessTokenBelongsToUser) Unscoped() *loginProcessTokenBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type loginProcessTokenBelongsToUserTx struct{ tx *gorm.Association } type loginProcessTokenBelongsToUserTx struct{ tx *gorm.Association }
func (a loginProcessTokenBelongsToUserTx) Find() (result *models.User, err error) { func (a loginProcessTokenBelongsToUserTx) Find() (result *models.User, err error) {
@ -422,6 +431,11 @@ func (a loginProcessTokenBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a loginProcessTokenBelongsToUserTx) Unscoped() *loginProcessTokenBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type loginProcessTokenDo struct{ gen.DO } type loginProcessTokenDo struct{ gen.DO }
type ILoginProcessTokenDo interface { type ILoginProcessTokenDo interface {
@ -479,6 +493,8 @@ type ILoginProcessTokenDo interface {
FirstOrCreate() (*models.LoginProcessToken, error) FirstOrCreate() (*models.LoginProcessToken, error)
FindByPage(offset int, limit int) (result []*models.LoginProcessToken, count int64, err error) FindByPage(offset int, limit int) (result []*models.LoginProcessToken, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) ILoginProcessTokenDo Returning(value interface{}, columns ...string) ILoginProcessTokenDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -182,6 +183,8 @@ type IMediaMetadataDo interface {
FirstOrCreate() (*models.MediaMetadata, error) FirstOrCreate() (*models.MediaMetadata, error)
FindByPage(offset int, limit int) (result []*models.MediaMetadata, count int64, err error) FindByPage(offset int, limit int) (result []*models.MediaMetadata, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IMediaMetadataDo Returning(value interface{}, columns ...string) IMediaMetadataDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -0,0 +1,983 @@
// 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"
"database/sql"
"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 newNoteEdit(db *gorm.DB, opts ...gen.DOOption) noteEdit {
_noteEdit := noteEdit{}
_noteEdit.noteEditDo.UseDB(db, opts...)
_noteEdit.noteEditDo.UseModel(&models.NoteEdit{})
tableName := _noteEdit.noteEditDo.TableName()
_noteEdit.ALL = field.NewAsterisk(tableName)
_noteEdit.NoteId = field.NewString(tableName, "note_id")
_noteEdit.EditNr = field.NewUint64(tableName, "edit_nr")
_noteEdit.CreatedAt = field.NewTime(tableName, "created_at")
_noteEdit.Before = field.NewString(tableName, "before")
_noteEdit.After = field.NewString(tableName, "after")
_noteEdit.Field = field.NewString(tableName, "field")
_noteEdit.Note = noteEditBelongsToNote{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("Note", "models.Note"),
Creator: struct {
field.RelationField
Server struct {
field.RelationField
Icon struct {
field.RelationField
}
Metadata struct {
field.RelationField
RemoteServer 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
}
Metadata struct {
field.RelationField
RemoteServer struct {
field.RelationField
}
}
}{
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
Icon: struct {
field.RelationField
}{
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
},
Metadata: struct {
field.RelationField
RemoteServer struct {
field.RelationField
}
}{
RelationField: field.NewRelation("Note.Creator.Server.Metadata", "models.RemoteServerMetadata"),
RemoteServer: struct {
field.RelationField
}{
RelationField: field.NewRelation("Note.Creator.Server.Metadata.RemoteServer", "models.RemoteServer"),
},
},
},
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"),
},
},
},
Origin: struct {
field.RelationField
}{
RelationField: field.NewRelation("Note.Origin", "models.RemoteServer"),
},
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"),
},
},
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"),
},
},
}
_noteEdit.fillFieldMap()
return _noteEdit
}
type noteEdit struct {
noteEditDo
ALL field.Asterisk
NoteId field.String
EditNr field.Uint64
CreatedAt field.Time
Before field.String
After field.String
Field field.String
Note noteEditBelongsToNote
fieldMap map[string]field.Expr
}
func (n noteEdit) Table(newTableName string) *noteEdit {
n.noteEditDo.UseTable(newTableName)
return n.updateTableName(newTableName)
}
func (n noteEdit) As(alias string) *noteEdit {
n.noteEditDo.DO = *(n.noteEditDo.As(alias).(*gen.DO))
return n.updateTableName(alias)
}
func (n *noteEdit) updateTableName(table string) *noteEdit {
n.ALL = field.NewAsterisk(table)
n.NoteId = field.NewString(table, "note_id")
n.EditNr = field.NewUint64(table, "edit_nr")
n.CreatedAt = field.NewTime(table, "created_at")
n.Before = field.NewString(table, "before")
n.After = field.NewString(table, "after")
n.Field = field.NewString(table, "field")
n.fillFieldMap()
return n
}
func (n *noteEdit) 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 *noteEdit) fillFieldMap() {
n.fieldMap = make(map[string]field.Expr, 7)
n.fieldMap["note_id"] = n.NoteId
n.fieldMap["edit_nr"] = n.EditNr
n.fieldMap["created_at"] = n.CreatedAt
n.fieldMap["before"] = n.Before
n.fieldMap["after"] = n.After
n.fieldMap["field"] = n.Field
}
func (n noteEdit) clone(db *gorm.DB) noteEdit {
n.noteEditDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
return n
}
func (n noteEdit) replaceDB(db *gorm.DB) noteEdit {
n.noteEditDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
return n
}
type noteEditBelongsToNote struct {
db *gorm.DB
field.RelationField
Creator struct {
field.RelationField
Server struct {
field.RelationField
Icon struct {
field.RelationField
}
Metadata struct {
field.RelationField
RemoteServer 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
}
}
}
Origin 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
}
}
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
}
func (a noteEditBelongsToNote) Where(conds ...field.Expr) *noteEditBelongsToNote {
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 noteEditBelongsToNote) WithContext(ctx context.Context) *noteEditBelongsToNote {
a.db = a.db.WithContext(ctx)
return &a
}
func (a noteEditBelongsToNote) Session(session *gorm.Session) *noteEditBelongsToNote {
a.db = a.db.Session(session)
return &a
}
func (a noteEditBelongsToNote) Model(m *models.NoteEdit) *noteEditBelongsToNoteTx {
return &noteEditBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
}
func (a noteEditBelongsToNote) Unscoped() *noteEditBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteEditBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteEditBelongsToNoteTx) Find() (result *models.Note, err error) {
return result, a.tx.Find(&result)
}
func (a noteEditBelongsToNoteTx) 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 noteEditBelongsToNoteTx) 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 noteEditBelongsToNoteTx) 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 noteEditBelongsToNoteTx) Clear() error {
return a.tx.Clear()
}
func (a noteEditBelongsToNoteTx) Count() int64 {
return a.tx.Count()
}
func (a noteEditBelongsToNoteTx) Unscoped() *noteEditBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteEditDo struct{ gen.DO }
type INoteEditDo interface {
gen.SubQuery
Debug() INoteEditDo
WithContext(ctx context.Context) INoteEditDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() INoteEditDo
WriteDB() INoteEditDo
As(alias string) gen.Dao
Session(config *gorm.Session) INoteEditDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) INoteEditDo
Not(conds ...gen.Condition) INoteEditDo
Or(conds ...gen.Condition) INoteEditDo
Select(conds ...field.Expr) INoteEditDo
Where(conds ...gen.Condition) INoteEditDo
Order(conds ...field.Expr) INoteEditDo
Distinct(cols ...field.Expr) INoteEditDo
Omit(cols ...field.Expr) INoteEditDo
Join(table schema.Tabler, on ...field.Expr) INoteEditDo
LeftJoin(table schema.Tabler, on ...field.Expr) INoteEditDo
RightJoin(table schema.Tabler, on ...field.Expr) INoteEditDo
Group(cols ...field.Expr) INoteEditDo
Having(conds ...gen.Condition) INoteEditDo
Limit(limit int) INoteEditDo
Offset(offset int) INoteEditDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteEditDo
Unscoped() INoteEditDo
Create(values ...*models.NoteEdit) error
CreateInBatches(values []*models.NoteEdit, batchSize int) error
Save(values ...*models.NoteEdit) error
First() (*models.NoteEdit, error)
Take() (*models.NoteEdit, error)
Last() (*models.NoteEdit, error)
Find() ([]*models.NoteEdit, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteEdit, err error)
FindInBatches(result *[]*models.NoteEdit, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*models.NoteEdit) (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) INoteEditDo
Assign(attrs ...field.AssignExpr) INoteEditDo
Joins(fields ...field.RelationField) INoteEditDo
Preload(fields ...field.RelationField) INoteEditDo
FirstOrInit() (*models.NoteEdit, error)
FirstOrCreate() (*models.NoteEdit, error)
FindByPage(offset int, limit int) (result []*models.NoteEdit, 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) INoteEditDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (n noteEditDo) Debug() INoteEditDo {
return n.withDO(n.DO.Debug())
}
func (n noteEditDo) WithContext(ctx context.Context) INoteEditDo {
return n.withDO(n.DO.WithContext(ctx))
}
func (n noteEditDo) ReadDB() INoteEditDo {
return n.Clauses(dbresolver.Read)
}
func (n noteEditDo) WriteDB() INoteEditDo {
return n.Clauses(dbresolver.Write)
}
func (n noteEditDo) Session(config *gorm.Session) INoteEditDo {
return n.withDO(n.DO.Session(config))
}
func (n noteEditDo) Clauses(conds ...clause.Expression) INoteEditDo {
return n.withDO(n.DO.Clauses(conds...))
}
func (n noteEditDo) Returning(value interface{}, columns ...string) INoteEditDo {
return n.withDO(n.DO.Returning(value, columns...))
}
func (n noteEditDo) Not(conds ...gen.Condition) INoteEditDo {
return n.withDO(n.DO.Not(conds...))
}
func (n noteEditDo) Or(conds ...gen.Condition) INoteEditDo {
return n.withDO(n.DO.Or(conds...))
}
func (n noteEditDo) Select(conds ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Select(conds...))
}
func (n noteEditDo) Where(conds ...gen.Condition) INoteEditDo {
return n.withDO(n.DO.Where(conds...))
}
func (n noteEditDo) Order(conds ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Order(conds...))
}
func (n noteEditDo) Distinct(cols ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Distinct(cols...))
}
func (n noteEditDo) Omit(cols ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Omit(cols...))
}
func (n noteEditDo) Join(table schema.Tabler, on ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Join(table, on...))
}
func (n noteEditDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteEditDo {
return n.withDO(n.DO.LeftJoin(table, on...))
}
func (n noteEditDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteEditDo {
return n.withDO(n.DO.RightJoin(table, on...))
}
func (n noteEditDo) Group(cols ...field.Expr) INoteEditDo {
return n.withDO(n.DO.Group(cols...))
}
func (n noteEditDo) Having(conds ...gen.Condition) INoteEditDo {
return n.withDO(n.DO.Having(conds...))
}
func (n noteEditDo) Limit(limit int) INoteEditDo {
return n.withDO(n.DO.Limit(limit))
}
func (n noteEditDo) Offset(offset int) INoteEditDo {
return n.withDO(n.DO.Offset(offset))
}
func (n noteEditDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteEditDo {
return n.withDO(n.DO.Scopes(funcs...))
}
func (n noteEditDo) Unscoped() INoteEditDo {
return n.withDO(n.DO.Unscoped())
}
func (n noteEditDo) Create(values ...*models.NoteEdit) error {
if len(values) == 0 {
return nil
}
return n.DO.Create(values)
}
func (n noteEditDo) CreateInBatches(values []*models.NoteEdit, 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 noteEditDo) Save(values ...*models.NoteEdit) error {
if len(values) == 0 {
return nil
}
return n.DO.Save(values)
}
func (n noteEditDo) First() (*models.NoteEdit, error) {
if result, err := n.DO.First(); err != nil {
return nil, err
} else {
return result.(*models.NoteEdit), nil
}
}
func (n noteEditDo) Take() (*models.NoteEdit, error) {
if result, err := n.DO.Take(); err != nil {
return nil, err
} else {
return result.(*models.NoteEdit), nil
}
}
func (n noteEditDo) Last() (*models.NoteEdit, error) {
if result, err := n.DO.Last(); err != nil {
return nil, err
} else {
return result.(*models.NoteEdit), nil
}
}
func (n noteEditDo) Find() ([]*models.NoteEdit, error) {
result, err := n.DO.Find()
return result.([]*models.NoteEdit), err
}
func (n noteEditDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteEdit, err error) {
buf := make([]*models.NoteEdit, 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 noteEditDo) FindInBatches(result *[]*models.NoteEdit, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return n.DO.FindInBatches(result, batchSize, fc)
}
func (n noteEditDo) Attrs(attrs ...field.AssignExpr) INoteEditDo {
return n.withDO(n.DO.Attrs(attrs...))
}
func (n noteEditDo) Assign(attrs ...field.AssignExpr) INoteEditDo {
return n.withDO(n.DO.Assign(attrs...))
}
func (n noteEditDo) Joins(fields ...field.RelationField) INoteEditDo {
for _, _f := range fields {
n = *n.withDO(n.DO.Joins(_f))
}
return &n
}
func (n noteEditDo) Preload(fields ...field.RelationField) INoteEditDo {
for _, _f := range fields {
n = *n.withDO(n.DO.Preload(_f))
}
return &n
}
func (n noteEditDo) FirstOrInit() (*models.NoteEdit, error) {
if result, err := n.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*models.NoteEdit), nil
}
}
func (n noteEditDo) FirstOrCreate() (*models.NoteEdit, error) {
if result, err := n.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*models.NoteEdit), nil
}
}
func (n noteEditDo) FindByPage(offset int, limit int) (result []*models.NoteEdit, 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 noteEditDo) 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 noteEditDo) Scan(result interface{}) (err error) {
return n.DO.Scan(result)
}
func (n noteEditDo) Delete(models ...*models.NoteEdit) (result gen.ResultInfo, err error) {
return n.DO.Delete(models)
}
func (n *noteEditDo) withDO(do gen.Dao) *noteEditDo {
n.DO = *do.(*gen.DO)
return n
}

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -383,6 +384,19 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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"),
},
},
} }
_noteTag.fillFieldMap() _noteTag.fillFieldMap()
@ -442,11 +456,14 @@ func (n *noteTag) fillFieldMap() {
func (n noteTag) clone(db *gorm.DB) noteTag { func (n noteTag) clone(db *gorm.DB) noteTag {
n.noteTagDo.ReplaceConnPool(db.Statement.ConnPool) n.noteTagDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n noteTag) replaceDB(db *gorm.DB) noteTag { func (n noteTag) replaceDB(db *gorm.DB) noteTag {
n.noteTagDo.ReplaceDB(db) n.noteTagDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
return n return n
} }
@ -575,6 +592,12 @@ type noteTagBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteTagBelongsToNote) Where(conds ...field.Expr) *noteTagBelongsToNote { func (a noteTagBelongsToNote) Where(conds ...field.Expr) *noteTagBelongsToNote {
@ -604,6 +627,11 @@ func (a noteTagBelongsToNote) Model(m *models.NoteTag) *noteTagBelongsToNoteTx {
return &noteTagBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteTagBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteTagBelongsToNote) Unscoped() *noteTagBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteTagBelongsToNoteTx struct{ tx *gorm.Association } type noteTagBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteTagBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteTagBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -642,6 +670,11 @@ func (a noteTagBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteTagBelongsToNoteTx) Unscoped() *noteTagBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteTagDo struct{ gen.DO } type noteTagDo struct{ gen.DO }
type INoteTagDo interface { type INoteTagDo interface {
@ -699,6 +732,8 @@ type INoteTagDo interface {
FirstOrCreate() (*models.NoteTag, error) FirstOrCreate() (*models.NoteTag, error)
FindByPage(offset int, limit int) (result []*models.NoteTag, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteTag, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteTagDo Returning(value interface{}, columns ...string) INoteTagDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -383,6 +384,19 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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"),
},
},
} }
_noteToAttachment.Attachment = noteToAttachmentBelongsToAttachment{ _noteToAttachment.Attachment = noteToAttachmentBelongsToAttachment{
@ -450,11 +464,17 @@ func (n *noteToAttachment) fillFieldMap() {
func (n noteToAttachment) clone(db *gorm.DB) noteToAttachment { func (n noteToAttachment) clone(db *gorm.DB) noteToAttachment {
n.noteToAttachmentDo.ReplaceConnPool(db.Statement.ConnPool) n.noteToAttachmentDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
n.Attachment.db = db.Session(&gorm.Session{Initialized: true})
n.Attachment.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n noteToAttachment) replaceDB(db *gorm.DB) noteToAttachment { func (n noteToAttachment) replaceDB(db *gorm.DB) noteToAttachment {
n.noteToAttachmentDo.ReplaceDB(db) n.noteToAttachmentDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
n.Attachment.db = db.Session(&gorm.Session{})
return n return n
} }
@ -583,6 +603,12 @@ type noteToAttachmentBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteToAttachmentBelongsToNote) Where(conds ...field.Expr) *noteToAttachmentBelongsToNote { func (a noteToAttachmentBelongsToNote) Where(conds ...field.Expr) *noteToAttachmentBelongsToNote {
@ -612,6 +638,11 @@ func (a noteToAttachmentBelongsToNote) Model(m *models.NoteToAttachment) *noteTo
return &noteToAttachmentBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteToAttachmentBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToAttachmentBelongsToNote) Unscoped() *noteToAttachmentBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteToAttachmentBelongsToNoteTx struct{ tx *gorm.Association } type noteToAttachmentBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteToAttachmentBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteToAttachmentBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -650,6 +681,11 @@ func (a noteToAttachmentBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToAttachmentBelongsToNoteTx) Unscoped() *noteToAttachmentBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToAttachmentBelongsToAttachment struct { type noteToAttachmentBelongsToAttachment struct {
db *gorm.DB db *gorm.DB
@ -683,6 +719,11 @@ func (a noteToAttachmentBelongsToAttachment) Model(m *models.NoteToAttachment) *
return &noteToAttachmentBelongsToAttachmentTx{a.db.Model(m).Association(a.Name())} return &noteToAttachmentBelongsToAttachmentTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToAttachmentBelongsToAttachment) Unscoped() *noteToAttachmentBelongsToAttachment {
a.db = a.db.Unscoped()
return &a
}
type noteToAttachmentBelongsToAttachmentTx struct{ tx *gorm.Association } type noteToAttachmentBelongsToAttachmentTx struct{ tx *gorm.Association }
func (a noteToAttachmentBelongsToAttachmentTx) Find() (result *models.MediaMetadata, err error) { func (a noteToAttachmentBelongsToAttachmentTx) Find() (result *models.MediaMetadata, err error) {
@ -721,6 +762,11 @@ func (a noteToAttachmentBelongsToAttachmentTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToAttachmentBelongsToAttachmentTx) Unscoped() *noteToAttachmentBelongsToAttachmentTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToAttachmentDo struct{ gen.DO } type noteToAttachmentDo struct{ gen.DO }
type INoteToAttachmentDo interface { type INoteToAttachmentDo interface {
@ -778,6 +824,8 @@ type INoteToAttachmentDo interface {
FirstOrCreate() (*models.NoteToAttachment, error) FirstOrCreate() (*models.NoteToAttachment, error)
FindByPage(offset int, limit int) (result []*models.NoteToAttachment, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteToAttachment, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteToAttachmentDo Returning(value interface{}, columns ...string) INoteToAttachmentDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -315,6 +316,19 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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() _noteToBoost.fillFieldMap()
@ -379,11 +393,17 @@ func (n *noteToBoost) fillFieldMap() {
func (n noteToBoost) clone(db *gorm.DB) noteToBoost { func (n noteToBoost) clone(db *gorm.DB) noteToBoost {
n.noteToBoostDo.ReplaceConnPool(db.Statement.ConnPool) 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 return n
} }
func (n noteToBoost) replaceDB(db *gorm.DB) noteToBoost { func (n noteToBoost) replaceDB(db *gorm.DB) noteToBoost {
n.noteToBoostDo.ReplaceDB(db) n.noteToBoostDo.ReplaceDB(db)
n.User.db = db.Session(&gorm.Session{})
n.Note.db = db.Session(&gorm.Session{})
return n return n
} }
@ -496,6 +516,11 @@ func (a noteToBoostBelongsToUser) Model(m *models.NoteToBoost) *noteToBoostBelon
return &noteToBoostBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &noteToBoostBelongsToUserTx{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 } type noteToBoostBelongsToUserTx struct{ tx *gorm.Association }
func (a noteToBoostBelongsToUserTx) Find() (result *models.User, err error) { func (a noteToBoostBelongsToUserTx) Find() (result *models.User, err error) {
@ -534,6 +559,11 @@ func (a noteToBoostBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToBoostBelongsToUserTx) Unscoped() *noteToBoostBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToBoostBelongsToNote struct { type noteToBoostBelongsToNote struct {
db *gorm.DB db *gorm.DB
@ -584,6 +614,12 @@ type noteToBoostBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteToBoostBelongsToNote) Where(conds ...field.Expr) *noteToBoostBelongsToNote { func (a noteToBoostBelongsToNote) Where(conds ...field.Expr) *noteToBoostBelongsToNote {
@ -613,6 +649,11 @@ func (a noteToBoostBelongsToNote) Model(m *models.NoteToBoost) *noteToBoostBelon
return &noteToBoostBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteToBoostBelongsToNoteTx{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 } type noteToBoostBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteToBoostBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteToBoostBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -651,6 +692,11 @@ func (a noteToBoostBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToBoostBelongsToNoteTx) Unscoped() *noteToBoostBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToBoostDo struct{ gen.DO } type noteToBoostDo struct{ gen.DO }
type INoteToBoostDo interface { type INoteToBoostDo interface {
@ -708,6 +754,8 @@ type INoteToBoostDo interface {
FirstOrCreate() (*models.NoteToBoost, error) FirstOrCreate() (*models.NoteToBoost, error)
FindByPage(offset int, limit int) (result []*models.NoteToBoost, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteToBoost, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteToBoostDo Returning(value interface{}, columns ...string) INoteToBoostDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -383,6 +384,19 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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"),
},
},
} }
_noteToEmote.Emote = noteToEmoteBelongsToEmote{ _noteToEmote.Emote = noteToEmoteBelongsToEmote{
@ -450,11 +464,17 @@ func (n *noteToEmote) fillFieldMap() {
func (n noteToEmote) clone(db *gorm.DB) noteToEmote { func (n noteToEmote) clone(db *gorm.DB) noteToEmote {
n.noteToEmoteDo.ReplaceConnPool(db.Statement.ConnPool) n.noteToEmoteDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
n.Emote.db = db.Session(&gorm.Session{Initialized: true})
n.Emote.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n noteToEmote) replaceDB(db *gorm.DB) noteToEmote { func (n noteToEmote) replaceDB(db *gorm.DB) noteToEmote {
n.noteToEmoteDo.ReplaceDB(db) n.noteToEmoteDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
n.Emote.db = db.Session(&gorm.Session{})
return n return n
} }
@ -583,6 +603,12 @@ type noteToEmoteBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteToEmoteBelongsToNote) Where(conds ...field.Expr) *noteToEmoteBelongsToNote { func (a noteToEmoteBelongsToNote) Where(conds ...field.Expr) *noteToEmoteBelongsToNote {
@ -612,6 +638,11 @@ func (a noteToEmoteBelongsToNote) Model(m *models.NoteToEmote) *noteToEmoteBelon
return &noteToEmoteBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteToEmoteBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToEmoteBelongsToNote) Unscoped() *noteToEmoteBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteToEmoteBelongsToNoteTx struct{ tx *gorm.Association } type noteToEmoteBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteToEmoteBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteToEmoteBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -650,6 +681,11 @@ func (a noteToEmoteBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToEmoteBelongsToNoteTx) Unscoped() *noteToEmoteBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToEmoteBelongsToEmote struct { type noteToEmoteBelongsToEmote struct {
db *gorm.DB db *gorm.DB
@ -683,6 +719,11 @@ func (a noteToEmoteBelongsToEmote) Model(m *models.NoteToEmote) *noteToEmoteBelo
return &noteToEmoteBelongsToEmoteTx{a.db.Model(m).Association(a.Name())} return &noteToEmoteBelongsToEmoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToEmoteBelongsToEmote) Unscoped() *noteToEmoteBelongsToEmote {
a.db = a.db.Unscoped()
return &a
}
type noteToEmoteBelongsToEmoteTx struct{ tx *gorm.Association } type noteToEmoteBelongsToEmoteTx struct{ tx *gorm.Association }
func (a noteToEmoteBelongsToEmoteTx) Find() (result *models.Emote, err error) { func (a noteToEmoteBelongsToEmoteTx) Find() (result *models.Emote, err error) {
@ -721,6 +762,11 @@ func (a noteToEmoteBelongsToEmoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToEmoteBelongsToEmoteTx) Unscoped() *noteToEmoteBelongsToEmoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToEmoteDo struct{ gen.DO } type noteToEmoteDo struct{ gen.DO }
type INoteToEmoteDo interface { type INoteToEmoteDo interface {
@ -778,6 +824,8 @@ type INoteToEmoteDo interface {
FirstOrCreate() (*models.NoteToEmote, error) FirstOrCreate() (*models.NoteToEmote, error)
FindByPage(offset int, limit int) (result []*models.NoteToEmote, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteToEmote, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteToEmoteDo Returning(value interface{}, columns ...string) INoteToEmoteDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -383,6 +384,19 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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"),
},
},
} }
_noteToFeed.fillFieldMap() _noteToFeed.fillFieldMap()
@ -442,11 +456,14 @@ func (n *noteToFeed) fillFieldMap() {
func (n noteToFeed) clone(db *gorm.DB) noteToFeed { func (n noteToFeed) clone(db *gorm.DB) noteToFeed {
n.noteToFeedDo.ReplaceConnPool(db.Statement.ConnPool) n.noteToFeedDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n noteToFeed) replaceDB(db *gorm.DB) noteToFeed { func (n noteToFeed) replaceDB(db *gorm.DB) noteToFeed {
n.noteToFeedDo.ReplaceDB(db) n.noteToFeedDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
return n return n
} }
@ -575,6 +592,12 @@ type noteToFeedBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteToFeedBelongsToNote) Where(conds ...field.Expr) *noteToFeedBelongsToNote { func (a noteToFeedBelongsToNote) Where(conds ...field.Expr) *noteToFeedBelongsToNote {
@ -604,6 +627,11 @@ func (a noteToFeedBelongsToNote) Model(m *models.NoteToFeed) *noteToFeedBelongsT
return &noteToFeedBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteToFeedBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToFeedBelongsToNote) Unscoped() *noteToFeedBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteToFeedBelongsToNoteTx struct{ tx *gorm.Association } type noteToFeedBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteToFeedBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteToFeedBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -642,6 +670,11 @@ func (a noteToFeedBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToFeedBelongsToNoteTx) Unscoped() *noteToFeedBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToFeedDo struct{ gen.DO } type noteToFeedDo struct{ gen.DO }
type INoteToFeedDo interface { type INoteToFeedDo interface {
@ -699,6 +732,8 @@ type INoteToFeedDo interface {
FirstOrCreate() (*models.NoteToFeed, error) FirstOrCreate() (*models.NoteToFeed, error)
FindByPage(offset int, limit int) (result []*models.NoteToFeed, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteToFeed, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteToFeedDo Returning(value interface{}, columns ...string) INoteToFeedDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -383,6 +384,19 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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"),
},
},
} }
_noteToPing.PingTarget = noteToPingBelongsToPingTarget{ _noteToPing.PingTarget = noteToPingBelongsToPingTarget{
@ -450,11 +464,17 @@ func (n *noteToPing) fillFieldMap() {
func (n noteToPing) clone(db *gorm.DB) noteToPing { func (n noteToPing) clone(db *gorm.DB) noteToPing {
n.noteToPingDo.ReplaceConnPool(db.Statement.ConnPool) n.noteToPingDo.ReplaceConnPool(db.Statement.ConnPool)
n.Note.db = db.Session(&gorm.Session{Initialized: true})
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
n.PingTarget.db = db.Session(&gorm.Session{Initialized: true})
n.PingTarget.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n noteToPing) replaceDB(db *gorm.DB) noteToPing { func (n noteToPing) replaceDB(db *gorm.DB) noteToPing {
n.noteToPingDo.ReplaceDB(db) n.noteToPingDo.ReplaceDB(db)
n.Note.db = db.Session(&gorm.Session{})
n.PingTarget.db = db.Session(&gorm.Session{})
return n return n
} }
@ -583,6 +603,12 @@ type noteToPingBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a noteToPingBelongsToNote) Where(conds ...field.Expr) *noteToPingBelongsToNote { func (a noteToPingBelongsToNote) Where(conds ...field.Expr) *noteToPingBelongsToNote {
@ -612,6 +638,11 @@ func (a noteToPingBelongsToNote) Model(m *models.NoteToPing) *noteToPingBelongsT
return &noteToPingBelongsToNoteTx{a.db.Model(m).Association(a.Name())} return &noteToPingBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToPingBelongsToNote) Unscoped() *noteToPingBelongsToNote {
a.db = a.db.Unscoped()
return &a
}
type noteToPingBelongsToNoteTx struct{ tx *gorm.Association } type noteToPingBelongsToNoteTx struct{ tx *gorm.Association }
func (a noteToPingBelongsToNoteTx) Find() (result *models.Note, err error) { func (a noteToPingBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -650,6 +681,11 @@ func (a noteToPingBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToPingBelongsToNoteTx) Unscoped() *noteToPingBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToPingBelongsToPingTarget struct { type noteToPingBelongsToPingTarget struct {
db *gorm.DB db *gorm.DB
@ -683,6 +719,11 @@ func (a noteToPingBelongsToPingTarget) Model(m *models.NoteToPing) *noteToPingBe
return &noteToPingBelongsToPingTargetTx{a.db.Model(m).Association(a.Name())} return &noteToPingBelongsToPingTargetTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteToPingBelongsToPingTarget) Unscoped() *noteToPingBelongsToPingTarget {
a.db = a.db.Unscoped()
return &a
}
type noteToPingBelongsToPingTargetTx struct{ tx *gorm.Association } type noteToPingBelongsToPingTargetTx struct{ tx *gorm.Association }
func (a noteToPingBelongsToPingTargetTx) Find() (result *models.User, err error) { func (a noteToPingBelongsToPingTargetTx) Find() (result *models.User, err error) {
@ -721,6 +762,11 @@ func (a noteToPingBelongsToPingTargetTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteToPingBelongsToPingTargetTx) Unscoped() *noteToPingBelongsToPingTargetTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteToPingDo struct{ gen.DO } type noteToPingDo struct{ gen.DO }
type INoteToPingDo interface { type INoteToPingDo interface {
@ -778,6 +824,8 @@ type INoteToPingDo interface {
FirstOrCreate() (*models.NoteToPing, error) FirstOrCreate() (*models.NoteToPing, error)
FindByPage(offset int, limit int) (result []*models.NoteToPing, count int64, err error) FindByPage(offset int, limit int) (result []*models.NoteToPing, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteToPingDo Returning(value interface{}, columns ...string) INoteToPingDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"strings" "strings"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
@ -159,6 +160,12 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
}{ }{
RelationField: field.NewRelation("AttachmentRelations.Note", "models.Note"), RelationField: field.NewRelation("AttachmentRelations.Note", "models.Note"),
Creator: struct { Creator: struct {
@ -495,6 +502,19 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
RelationField: field.NewRelation("AttachmentRelations.Note.Tags.Note", "models.Note"), RelationField: field.NewRelation("AttachmentRelations.Note.Tags.Note", "models.Note"),
}, },
}, },
Edits: struct {
field.RelationField
Note struct {
field.RelationField
}
}{
RelationField: field.NewRelation("AttachmentRelations.Note.Edits", "models.NoteEdit"),
Note: struct {
field.RelationField
}{
RelationField: field.NewRelation("AttachmentRelations.Note.Edits.Note", "models.Note"),
},
},
}, },
Attachment: struct { Attachment: struct {
field.RelationField field.RelationField
@ -521,6 +541,12 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
RelationField: field.NewRelation("Tags", "models.NoteTag"), RelationField: field.NewRelation("Tags", "models.NoteTag"),
} }
_note.Edits = noteHasManyEdits{
db: db.Session(&gorm.Session{}),
RelationField: field.NewRelation("Edits", "models.NoteEdit"),
}
_note.Creator = noteBelongsToCreator{ _note.Creator = noteBelongsToCreator{
db: db.Session(&gorm.Session{}), db: db.Session(&gorm.Session{}),
@ -562,6 +588,8 @@ type note struct {
Tags noteHasManyTags Tags noteHasManyTags
Edits noteHasManyEdits
Creator noteBelongsToCreator Creator noteBelongsToCreator
Origin noteBelongsToOrigin Origin noteBelongsToOrigin
@ -609,7 +637,7 @@ func (n *note) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
} }
func (n *note) fillFieldMap() { func (n *note) fillFieldMap() {
n.fieldMap = make(map[string]field.Expr, 18) n.fieldMap = make(map[string]field.Expr, 19)
n.fieldMap["id"] = n.ID n.fieldMap["id"] = n.ID
n.fieldMap["created_at"] = n.CreatedAt n.fieldMap["created_at"] = n.CreatedAt
n.fieldMap["updated_at"] = n.UpdatedAt n.fieldMap["updated_at"] = n.UpdatedAt
@ -627,11 +655,32 @@ func (n *note) fillFieldMap() {
func (n note) clone(db *gorm.DB) note { func (n note) clone(db *gorm.DB) note {
n.noteDo.ReplaceConnPool(db.Statement.ConnPool) n.noteDo.ReplaceConnPool(db.Statement.ConnPool)
n.AttachmentRelations.db = db.Session(&gorm.Session{Initialized: true})
n.AttachmentRelations.db.Statement.ConnPool = db.Statement.ConnPool
n.EmoteRelations.db = db.Session(&gorm.Session{Initialized: true})
n.EmoteRelations.db.Statement.ConnPool = db.Statement.ConnPool
n.PingRelations.db = db.Session(&gorm.Session{Initialized: true})
n.PingRelations.db.Statement.ConnPool = db.Statement.ConnPool
n.Tags.db = db.Session(&gorm.Session{Initialized: true})
n.Tags.db.Statement.ConnPool = db.Statement.ConnPool
n.Edits.db = db.Session(&gorm.Session{Initialized: true})
n.Edits.db.Statement.ConnPool = db.Statement.ConnPool
n.Creator.db = db.Session(&gorm.Session{Initialized: true})
n.Creator.db.Statement.ConnPool = db.Statement.ConnPool
n.Origin.db = db.Session(&gorm.Session{Initialized: true})
n.Origin.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n note) replaceDB(db *gorm.DB) note { func (n note) replaceDB(db *gorm.DB) note {
n.noteDo.ReplaceDB(db) n.noteDo.ReplaceDB(db)
n.AttachmentRelations.db = db.Session(&gorm.Session{})
n.EmoteRelations.db = db.Session(&gorm.Session{})
n.PingRelations.db = db.Session(&gorm.Session{})
n.Tags.db = db.Session(&gorm.Session{})
n.Edits.db = db.Session(&gorm.Session{})
n.Creator.db = db.Session(&gorm.Session{})
n.Origin.db = db.Session(&gorm.Session{})
return n return n
} }
@ -756,6 +805,12 @@ type noteHasManyAttachmentRelations struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
Attachment struct { Attachment struct {
field.RelationField field.RelationField
@ -789,6 +844,11 @@ func (a noteHasManyAttachmentRelations) Model(m *models.Note) *noteHasManyAttach
return &noteHasManyAttachmentRelationsTx{a.db.Model(m).Association(a.Name())} return &noteHasManyAttachmentRelationsTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteHasManyAttachmentRelations) Unscoped() *noteHasManyAttachmentRelations {
a.db = a.db.Unscoped()
return &a
}
type noteHasManyAttachmentRelationsTx struct{ tx *gorm.Association } type noteHasManyAttachmentRelationsTx struct{ tx *gorm.Association }
func (a noteHasManyAttachmentRelationsTx) Find() (result []*models.NoteToAttachment, err error) { func (a noteHasManyAttachmentRelationsTx) Find() (result []*models.NoteToAttachment, err error) {
@ -827,6 +887,11 @@ func (a noteHasManyAttachmentRelationsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteHasManyAttachmentRelationsTx) Unscoped() *noteHasManyAttachmentRelationsTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteHasManyEmoteRelations struct { type noteHasManyEmoteRelations struct {
db *gorm.DB db *gorm.DB
@ -860,6 +925,11 @@ func (a noteHasManyEmoteRelations) Model(m *models.Note) *noteHasManyEmoteRelati
return &noteHasManyEmoteRelationsTx{a.db.Model(m).Association(a.Name())} return &noteHasManyEmoteRelationsTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteHasManyEmoteRelations) Unscoped() *noteHasManyEmoteRelations {
a.db = a.db.Unscoped()
return &a
}
type noteHasManyEmoteRelationsTx struct{ tx *gorm.Association } type noteHasManyEmoteRelationsTx struct{ tx *gorm.Association }
func (a noteHasManyEmoteRelationsTx) Find() (result []*models.NoteToEmote, err error) { func (a noteHasManyEmoteRelationsTx) Find() (result []*models.NoteToEmote, err error) {
@ -898,6 +968,11 @@ func (a noteHasManyEmoteRelationsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteHasManyEmoteRelationsTx) Unscoped() *noteHasManyEmoteRelationsTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteHasManyPingRelations struct { type noteHasManyPingRelations struct {
db *gorm.DB db *gorm.DB
@ -931,6 +1006,11 @@ func (a noteHasManyPingRelations) Model(m *models.Note) *noteHasManyPingRelation
return &noteHasManyPingRelationsTx{a.db.Model(m).Association(a.Name())} return &noteHasManyPingRelationsTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteHasManyPingRelations) Unscoped() *noteHasManyPingRelations {
a.db = a.db.Unscoped()
return &a
}
type noteHasManyPingRelationsTx struct{ tx *gorm.Association } type noteHasManyPingRelationsTx struct{ tx *gorm.Association }
func (a noteHasManyPingRelationsTx) Find() (result []*models.NoteToPing, err error) { func (a noteHasManyPingRelationsTx) Find() (result []*models.NoteToPing, err error) {
@ -969,6 +1049,11 @@ func (a noteHasManyPingRelationsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteHasManyPingRelationsTx) Unscoped() *noteHasManyPingRelationsTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteHasManyTags struct { type noteHasManyTags struct {
db *gorm.DB db *gorm.DB
@ -1002,6 +1087,11 @@ func (a noteHasManyTags) Model(m *models.Note) *noteHasManyTagsTx {
return &noteHasManyTagsTx{a.db.Model(m).Association(a.Name())} return &noteHasManyTagsTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteHasManyTags) Unscoped() *noteHasManyTags {
a.db = a.db.Unscoped()
return &a
}
type noteHasManyTagsTx struct{ tx *gorm.Association } type noteHasManyTagsTx struct{ tx *gorm.Association }
func (a noteHasManyTagsTx) Find() (result []*models.NoteTag, err error) { func (a noteHasManyTagsTx) Find() (result []*models.NoteTag, err error) {
@ -1040,6 +1130,92 @@ func (a noteHasManyTagsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteHasManyTagsTx) Unscoped() *noteHasManyTagsTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteHasManyEdits struct {
db *gorm.DB
field.RelationField
}
func (a noteHasManyEdits) Where(conds ...field.Expr) *noteHasManyEdits {
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 noteHasManyEdits) WithContext(ctx context.Context) *noteHasManyEdits {
a.db = a.db.WithContext(ctx)
return &a
}
func (a noteHasManyEdits) Session(session *gorm.Session) *noteHasManyEdits {
a.db = a.db.Session(session)
return &a
}
func (a noteHasManyEdits) Model(m *models.Note) *noteHasManyEditsTx {
return &noteHasManyEditsTx{a.db.Model(m).Association(a.Name())}
}
func (a noteHasManyEdits) Unscoped() *noteHasManyEdits {
a.db = a.db.Unscoped()
return &a
}
type noteHasManyEditsTx struct{ tx *gorm.Association }
func (a noteHasManyEditsTx) Find() (result []*models.NoteEdit, err error) {
return result, a.tx.Find(&result)
}
func (a noteHasManyEditsTx) Append(values ...*models.NoteEdit) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Append(targetValues...)
}
func (a noteHasManyEditsTx) Replace(values ...*models.NoteEdit) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Replace(targetValues...)
}
func (a noteHasManyEditsTx) Delete(values ...*models.NoteEdit) (err error) {
targetValues := make([]interface{}, len(values))
for i, v := range values {
targetValues[i] = v
}
return a.tx.Delete(targetValues...)
}
func (a noteHasManyEditsTx) Clear() error {
return a.tx.Clear()
}
func (a noteHasManyEditsTx) Count() int64 {
return a.tx.Count()
}
func (a noteHasManyEditsTx) Unscoped() *noteHasManyEditsTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteBelongsToCreator struct { type noteBelongsToCreator struct {
db *gorm.DB db *gorm.DB
@ -1073,6 +1249,11 @@ func (a noteBelongsToCreator) Model(m *models.Note) *noteBelongsToCreatorTx {
return &noteBelongsToCreatorTx{a.db.Model(m).Association(a.Name())} return &noteBelongsToCreatorTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteBelongsToCreator) Unscoped() *noteBelongsToCreator {
a.db = a.db.Unscoped()
return &a
}
type noteBelongsToCreatorTx struct{ tx *gorm.Association } type noteBelongsToCreatorTx struct{ tx *gorm.Association }
func (a noteBelongsToCreatorTx) Find() (result *models.User, err error) { func (a noteBelongsToCreatorTx) Find() (result *models.User, err error) {
@ -1111,6 +1292,11 @@ func (a noteBelongsToCreatorTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteBelongsToCreatorTx) Unscoped() *noteBelongsToCreatorTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteBelongsToOrigin struct { type noteBelongsToOrigin struct {
db *gorm.DB db *gorm.DB
@ -1144,6 +1330,11 @@ func (a noteBelongsToOrigin) Model(m *models.Note) *noteBelongsToOriginTx {
return &noteBelongsToOriginTx{a.db.Model(m).Association(a.Name())} return &noteBelongsToOriginTx{a.db.Model(m).Association(a.Name())}
} }
func (a noteBelongsToOrigin) Unscoped() *noteBelongsToOrigin {
a.db = a.db.Unscoped()
return &a
}
type noteBelongsToOriginTx struct{ tx *gorm.Association } type noteBelongsToOriginTx struct{ tx *gorm.Association }
func (a noteBelongsToOriginTx) Find() (result *models.RemoteServer, err error) { func (a noteBelongsToOriginTx) Find() (result *models.RemoteServer, err error) {
@ -1182,6 +1373,11 @@ func (a noteBelongsToOriginTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a noteBelongsToOriginTx) Unscoped() *noteBelongsToOriginTx {
a.tx = a.tx.Unscoped()
return &a
}
type noteDo struct{ gen.DO } type noteDo struct{ gen.DO }
type INoteDo interface { type INoteDo interface {
@ -1239,6 +1435,8 @@ type INoteDo interface {
FirstOrCreate() (*models.Note, error) FirstOrCreate() (*models.Note, error)
FindByPage(offset int, limit int) (result []*models.Note, count int64, err error) FindByPage(offset int, limit int) (result []*models.Note, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INoteDo Returning(value interface{}, columns ...string) INoteDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"strings" "strings"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
@ -321,6 +322,19 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
RelationField: field.NewRelation("SourceNote.Tags.Note", "models.Note"), RelationField: field.NewRelation("SourceNote.Tags.Note", "models.Note"),
}, },
}, },
Edits: struct {
field.RelationField
Note struct {
field.RelationField
}
}{
RelationField: field.NewRelation("SourceNote.Edits", "models.NoteEdit"),
Note: struct {
field.RelationField
}{
RelationField: field.NewRelation("SourceNote.Edits.Note", "models.Note"),
},
},
} }
_notification.SourceUser = notificationBelongsToSourceUser{ _notification.SourceUser = notificationBelongsToSourceUser{
@ -408,11 +422,20 @@ func (n *notification) fillFieldMap() {
func (n notification) clone(db *gorm.DB) notification { func (n notification) clone(db *gorm.DB) notification {
n.notificationDo.ReplaceConnPool(db.Statement.ConnPool) n.notificationDo.ReplaceConnPool(db.Statement.ConnPool)
n.ForUser.db = db.Session(&gorm.Session{Initialized: true})
n.ForUser.db.Statement.ConnPool = db.Statement.ConnPool
n.SourceNote.db = db.Session(&gorm.Session{Initialized: true})
n.SourceNote.db.Statement.ConnPool = db.Statement.ConnPool
n.SourceUser.db = db.Session(&gorm.Session{Initialized: true})
n.SourceUser.db.Statement.ConnPool = db.Statement.ConnPool
return n return n
} }
func (n notification) replaceDB(db *gorm.DB) notification { func (n notification) replaceDB(db *gorm.DB) notification {
n.notificationDo.ReplaceDB(db) n.notificationDo.ReplaceDB(db)
n.ForUser.db = db.Session(&gorm.Session{})
n.SourceNote.db = db.Session(&gorm.Session{})
n.SourceUser.db = db.Session(&gorm.Session{})
return n return n
} }
@ -525,6 +548,11 @@ func (a notificationBelongsToForUser) Model(m *models.Notification) *notificatio
return &notificationBelongsToForUserTx{a.db.Model(m).Association(a.Name())} return &notificationBelongsToForUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a notificationBelongsToForUser) Unscoped() *notificationBelongsToForUser {
a.db = a.db.Unscoped()
return &a
}
type notificationBelongsToForUserTx struct{ tx *gorm.Association } type notificationBelongsToForUserTx struct{ tx *gorm.Association }
func (a notificationBelongsToForUserTx) Find() (result *models.User, err error) { func (a notificationBelongsToForUserTx) Find() (result *models.User, err error) {
@ -563,6 +591,11 @@ func (a notificationBelongsToForUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a notificationBelongsToForUserTx) Unscoped() *notificationBelongsToForUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type notificationBelongsToSourceNote struct { type notificationBelongsToSourceNote struct {
db *gorm.DB db *gorm.DB
@ -613,6 +646,12 @@ type notificationBelongsToSourceNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a notificationBelongsToSourceNote) Where(conds ...field.Expr) *notificationBelongsToSourceNote { func (a notificationBelongsToSourceNote) Where(conds ...field.Expr) *notificationBelongsToSourceNote {
@ -642,6 +681,11 @@ func (a notificationBelongsToSourceNote) Model(m *models.Notification) *notifica
return &notificationBelongsToSourceNoteTx{a.db.Model(m).Association(a.Name())} return &notificationBelongsToSourceNoteTx{a.db.Model(m).Association(a.Name())}
} }
func (a notificationBelongsToSourceNote) Unscoped() *notificationBelongsToSourceNote {
a.db = a.db.Unscoped()
return &a
}
type notificationBelongsToSourceNoteTx struct{ tx *gorm.Association } type notificationBelongsToSourceNoteTx struct{ tx *gorm.Association }
func (a notificationBelongsToSourceNoteTx) Find() (result *models.Note, err error) { func (a notificationBelongsToSourceNoteTx) Find() (result *models.Note, err error) {
@ -680,6 +724,11 @@ func (a notificationBelongsToSourceNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a notificationBelongsToSourceNoteTx) Unscoped() *notificationBelongsToSourceNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type notificationBelongsToSourceUser struct { type notificationBelongsToSourceUser struct {
db *gorm.DB db *gorm.DB
@ -713,6 +762,11 @@ func (a notificationBelongsToSourceUser) Model(m *models.Notification) *notifica
return &notificationBelongsToSourceUserTx{a.db.Model(m).Association(a.Name())} return &notificationBelongsToSourceUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a notificationBelongsToSourceUser) Unscoped() *notificationBelongsToSourceUser {
a.db = a.db.Unscoped()
return &a
}
type notificationBelongsToSourceUserTx struct{ tx *gorm.Association } type notificationBelongsToSourceUserTx struct{ tx *gorm.Association }
func (a notificationBelongsToSourceUserTx) Find() (result *models.User, err error) { func (a notificationBelongsToSourceUserTx) Find() (result *models.User, err error) {
@ -751,6 +805,11 @@ func (a notificationBelongsToSourceUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a notificationBelongsToSourceUserTx) Unscoped() *notificationBelongsToSourceUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type notificationDo struct{ gen.DO } type notificationDo struct{ gen.DO }
type INotificationDo interface { type INotificationDo interface {
@ -808,6 +867,8 @@ type INotificationDo interface {
FirstOrCreate() (*models.Notification, error) FirstOrCreate() (*models.Notification, error)
FindByPage(offset int, limit int) (result []*models.Notification, count int64, err error) FindByPage(offset int, limit int) (result []*models.Notification, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) INotificationDo Returning(value interface{}, columns ...string) INotificationDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -387,6 +388,19 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"), 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{ _reaction.Reactor = reactionBelongsToReactor{
@ -474,11 +488,20 @@ func (r *reaction) fillFieldMap() {
func (r reaction) clone(db *gorm.DB) reaction { func (r reaction) clone(db *gorm.DB) reaction {
r.reactionDo.ReplaceConnPool(db.Statement.ConnPool) 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 return r
} }
func (r reaction) replaceDB(db *gorm.DB) reaction { func (r reaction) replaceDB(db *gorm.DB) reaction {
r.reactionDo.ReplaceDB(db) 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 return r
} }
@ -607,6 +630,12 @@ type reactionBelongsToNote struct {
field.RelationField field.RelationField
} }
} }
Edits struct {
field.RelationField
Note struct {
field.RelationField
}
}
} }
func (a reactionBelongsToNote) Where(conds ...field.Expr) *reactionBelongsToNote { 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())} 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 } type reactionBelongsToNoteTx struct{ tx *gorm.Association }
func (a reactionBelongsToNoteTx) Find() (result *models.Note, err error) { func (a reactionBelongsToNoteTx) Find() (result *models.Note, err error) {
@ -674,6 +708,11 @@ func (a reactionBelongsToNoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a reactionBelongsToNoteTx) Unscoped() *reactionBelongsToNoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type reactionBelongsToReactor struct { type reactionBelongsToReactor struct {
db *gorm.DB db *gorm.DB
@ -707,6 +746,11 @@ func (a reactionBelongsToReactor) Model(m *models.Reaction) *reactionBelongsToRe
return &reactionBelongsToReactorTx{a.db.Model(m).Association(a.Name())} 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 } type reactionBelongsToReactorTx struct{ tx *gorm.Association }
func (a reactionBelongsToReactorTx) Find() (result *models.User, err error) { func (a reactionBelongsToReactorTx) Find() (result *models.User, err error) {
@ -745,6 +789,11 @@ func (a reactionBelongsToReactorTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a reactionBelongsToReactorTx) Unscoped() *reactionBelongsToReactorTx {
a.tx = a.tx.Unscoped()
return &a
}
type reactionBelongsToEmote struct { type reactionBelongsToEmote struct {
db *gorm.DB db *gorm.DB
@ -778,6 +827,11 @@ func (a reactionBelongsToEmote) Model(m *models.Reaction) *reactionBelongsToEmot
return &reactionBelongsToEmoteTx{a.db.Model(m).Association(a.Name())} 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 } type reactionBelongsToEmoteTx struct{ tx *gorm.Association }
func (a reactionBelongsToEmoteTx) Find() (result *models.Emote, err error) { func (a reactionBelongsToEmoteTx) Find() (result *models.Emote, err error) {
@ -816,6 +870,11 @@ func (a reactionBelongsToEmoteTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a reactionBelongsToEmoteTx) Unscoped() *reactionBelongsToEmoteTx {
a.tx = a.tx.Unscoped()
return &a
}
type reactionDo struct{ gen.DO } type reactionDo struct{ gen.DO }
type IReactionDo interface { type IReactionDo interface {
@ -873,6 +932,8 @@ type IReactionDo interface {
FirstOrCreate() (*models.Reaction, error) FirstOrCreate() (*models.Reaction, error)
FindByPage(offset int, limit int) (result []*models.Reaction, count int64, err error) FindByPage(offset int, limit int) (result []*models.Reaction, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IReactionDo Returning(value interface{}, columns ...string) IReactionDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -126,11 +127,14 @@ func (r *remoteServerMetadata) fillFieldMap() {
func (r remoteServerMetadata) clone(db *gorm.DB) remoteServerMetadata { func (r remoteServerMetadata) clone(db *gorm.DB) remoteServerMetadata {
r.remoteServerMetadataDo.ReplaceConnPool(db.Statement.ConnPool) r.remoteServerMetadataDo.ReplaceConnPool(db.Statement.ConnPool)
r.RemoteServer.db = db.Session(&gorm.Session{Initialized: true})
r.RemoteServer.db.Statement.ConnPool = db.Statement.ConnPool
return r return r
} }
func (r remoteServerMetadata) replaceDB(db *gorm.DB) remoteServerMetadata { func (r remoteServerMetadata) replaceDB(db *gorm.DB) remoteServerMetadata {
r.remoteServerMetadataDo.ReplaceDB(db) r.remoteServerMetadataDo.ReplaceDB(db)
r.RemoteServer.db = db.Session(&gorm.Session{})
return r return r
} }
@ -177,6 +181,11 @@ func (a remoteServerMetadataBelongsToRemoteServer) Model(m *models.RemoteServerM
return &remoteServerMetadataBelongsToRemoteServerTx{a.db.Model(m).Association(a.Name())} return &remoteServerMetadataBelongsToRemoteServerTx{a.db.Model(m).Association(a.Name())}
} }
func (a remoteServerMetadataBelongsToRemoteServer) Unscoped() *remoteServerMetadataBelongsToRemoteServer {
a.db = a.db.Unscoped()
return &a
}
type remoteServerMetadataBelongsToRemoteServerTx struct{ tx *gorm.Association } type remoteServerMetadataBelongsToRemoteServerTx struct{ tx *gorm.Association }
func (a remoteServerMetadataBelongsToRemoteServerTx) Find() (result *models.RemoteServer, err error) { func (a remoteServerMetadataBelongsToRemoteServerTx) Find() (result *models.RemoteServer, err error) {
@ -215,6 +224,11 @@ func (a remoteServerMetadataBelongsToRemoteServerTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a remoteServerMetadataBelongsToRemoteServerTx) Unscoped() *remoteServerMetadataBelongsToRemoteServerTx {
a.tx = a.tx.Unscoped()
return &a
}
type remoteServerMetadataDo struct{ gen.DO } type remoteServerMetadataDo struct{ gen.DO }
type IRemoteServerMetadataDo interface { type IRemoteServerMetadataDo interface {
@ -272,6 +286,8 @@ type IRemoteServerMetadataDo interface {
FirstOrCreate() (*models.RemoteServerMetadata, error) FirstOrCreate() (*models.RemoteServerMetadata, error)
FindByPage(offset int, limit int) (result []*models.RemoteServerMetadata, count int64, err error) FindByPage(offset int, limit int) (result []*models.RemoteServerMetadata, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IRemoteServerMetadataDo Returning(value interface{}, columns ...string) IRemoteServerMetadataDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -153,11 +154,17 @@ func (r *remoteServer) fillFieldMap() {
func (r remoteServer) clone(db *gorm.DB) remoteServer { func (r remoteServer) clone(db *gorm.DB) remoteServer {
r.remoteServerDo.ReplaceConnPool(db.Statement.ConnPool) 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 return r
} }
func (r remoteServer) replaceDB(db *gorm.DB) remoteServer { func (r remoteServer) replaceDB(db *gorm.DB) remoteServer {
r.remoteServerDo.ReplaceDB(db) r.remoteServerDo.ReplaceDB(db)
r.Metadata.db = db.Session(&gorm.Session{})
r.Icon.db = db.Session(&gorm.Session{})
return r return r
} }
@ -204,6 +211,11 @@ func (a remoteServerHasManyMetadata) Model(m *models.RemoteServer) *remoteServer
return &remoteServerHasManyMetadataTx{a.db.Model(m).Association(a.Name())} 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 } type remoteServerHasManyMetadataTx struct{ tx *gorm.Association }
func (a remoteServerHasManyMetadataTx) Find() (result []*models.RemoteServerMetadata, err error) { func (a remoteServerHasManyMetadataTx) Find() (result []*models.RemoteServerMetadata, err error) {
@ -242,6 +254,11 @@ func (a remoteServerHasManyMetadataTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a remoteServerHasManyMetadataTx) Unscoped() *remoteServerHasManyMetadataTx {
a.tx = a.tx.Unscoped()
return &a
}
type remoteServerBelongsToIcon struct { type remoteServerBelongsToIcon struct {
db *gorm.DB db *gorm.DB
@ -275,6 +292,11 @@ func (a remoteServerBelongsToIcon) Model(m *models.RemoteServer) *remoteServerBe
return &remoteServerBelongsToIconTx{a.db.Model(m).Association(a.Name())} 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 } type remoteServerBelongsToIconTx struct{ tx *gorm.Association }
func (a remoteServerBelongsToIconTx) Find() (result *models.MediaMetadata, err error) { func (a remoteServerBelongsToIconTx) Find() (result *models.MediaMetadata, err error) {
@ -313,6 +335,11 @@ func (a remoteServerBelongsToIconTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a remoteServerBelongsToIconTx) Unscoped() *remoteServerBelongsToIconTx {
a.tx = a.tx.Unscoped()
return &a
}
type remoteServerDo struct{ gen.DO } type remoteServerDo struct{ gen.DO }
type IRemoteServerDo interface { type IRemoteServerDo interface {
@ -370,6 +397,8 @@ type IRemoteServerDo interface {
FirstOrCreate() (*models.RemoteServer, error) FirstOrCreate() (*models.RemoteServer, error)
FindByPage(offset int, limit int) (result []*models.RemoteServer, count int64, err error) FindByPage(offset int, limit int) (result []*models.RemoteServer, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IRemoteServerDo Returning(value interface{}, columns ...string) IRemoteServerDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -350,6 +351,8 @@ type IRoleDo interface {
FirstOrCreate() (*models.Role, error) FirstOrCreate() (*models.Role, error)
FindByPage(offset int, limit int) (result []*models.Role, count int64, err error) FindByPage(offset int, limit int) (result []*models.Role, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IRoleDo Returning(value interface{}, columns ...string) IRoleDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -279,11 +280,14 @@ func (u *userAuthMethod) fillFieldMap() {
func (u userAuthMethod) clone(db *gorm.DB) userAuthMethod { func (u userAuthMethod) clone(db *gorm.DB) userAuthMethod {
u.userAuthMethodDo.ReplaceConnPool(db.Statement.ConnPool) u.userAuthMethodDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userAuthMethod) replaceDB(db *gorm.DB) userAuthMethod { func (u userAuthMethod) replaceDB(db *gorm.DB) userAuthMethod {
u.userAuthMethodDo.ReplaceDB(db) u.userAuthMethodDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -396,6 +400,11 @@ func (a userAuthMethodBelongsToUser) Model(m *models.UserAuthMethod) *userAuthMe
return &userAuthMethodBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userAuthMethodBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userAuthMethodBelongsToUser) Unscoped() *userAuthMethodBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userAuthMethodBelongsToUserTx struct{ tx *gorm.Association } type userAuthMethodBelongsToUserTx struct{ tx *gorm.Association }
func (a userAuthMethodBelongsToUserTx) Find() (result *models.User, err error) { func (a userAuthMethodBelongsToUserTx) Find() (result *models.User, err error) {
@ -434,6 +443,11 @@ func (a userAuthMethodBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userAuthMethodBelongsToUserTx) Unscoped() *userAuthMethodBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userAuthMethodDo struct{ gen.DO } type userAuthMethodDo struct{ gen.DO }
type IUserAuthMethodDo interface { type IUserAuthMethodDo interface {
@ -491,6 +505,8 @@ type IUserAuthMethodDo interface {
FirstOrCreate() (*models.UserAuthMethod, error) FirstOrCreate() (*models.UserAuthMethod, error)
FindByPage(offset int, limit int) (result []*models.UserAuthMethod, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserAuthMethod, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserAuthMethodDo Returning(value interface{}, columns ...string) IUserAuthMethodDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -283,11 +284,14 @@ func (u *userInfoField) fillFieldMap() {
func (u userInfoField) clone(db *gorm.DB) userInfoField { func (u userInfoField) clone(db *gorm.DB) userInfoField {
u.userInfoFieldDo.ReplaceConnPool(db.Statement.ConnPool) u.userInfoFieldDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userInfoField) replaceDB(db *gorm.DB) userInfoField { func (u userInfoField) replaceDB(db *gorm.DB) userInfoField {
u.userInfoFieldDo.ReplaceDB(db) u.userInfoFieldDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -400,6 +404,11 @@ func (a userInfoFieldBelongsToUser) Model(m *models.UserInfoField) *userInfoFiel
return &userInfoFieldBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userInfoFieldBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userInfoFieldBelongsToUser) Unscoped() *userInfoFieldBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userInfoFieldBelongsToUserTx struct{ tx *gorm.Association } type userInfoFieldBelongsToUserTx struct{ tx *gorm.Association }
func (a userInfoFieldBelongsToUserTx) Find() (result *models.User, err error) { func (a userInfoFieldBelongsToUserTx) Find() (result *models.User, err error) {
@ -438,6 +447,11 @@ func (a userInfoFieldBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userInfoFieldBelongsToUserTx) Unscoped() *userInfoFieldBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userInfoFieldDo struct{ gen.DO } type userInfoFieldDo struct{ gen.DO }
type IUserInfoFieldDo interface { type IUserInfoFieldDo interface {
@ -495,6 +509,8 @@ type IUserInfoFieldDo interface {
FirstOrCreate() (*models.UserInfoField, error) FirstOrCreate() (*models.UserInfoField, error)
FindByPage(offset int, limit int) (result []*models.UserInfoField, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserInfoField, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserInfoFieldDo Returning(value interface{}, columns ...string) IUserInfoFieldDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -299,11 +300,14 @@ func (u *userRemoteLinks) fillFieldMap() {
func (u userRemoteLinks) clone(db *gorm.DB) userRemoteLinks { func (u userRemoteLinks) clone(db *gorm.DB) userRemoteLinks {
u.userRemoteLinksDo.ReplaceConnPool(db.Statement.ConnPool) u.userRemoteLinksDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userRemoteLinks) replaceDB(db *gorm.DB) userRemoteLinks { func (u userRemoteLinks) replaceDB(db *gorm.DB) userRemoteLinks {
u.userRemoteLinksDo.ReplaceDB(db) u.userRemoteLinksDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -416,6 +420,11 @@ func (a userRemoteLinksBelongsToUser) Model(m *models.UserRemoteLinks) *userRemo
return &userRemoteLinksBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userRemoteLinksBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userRemoteLinksBelongsToUser) Unscoped() *userRemoteLinksBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userRemoteLinksBelongsToUserTx struct{ tx *gorm.Association } type userRemoteLinksBelongsToUserTx struct{ tx *gorm.Association }
func (a userRemoteLinksBelongsToUserTx) Find() (result *models.User, err error) { func (a userRemoteLinksBelongsToUserTx) Find() (result *models.User, err error) {
@ -454,6 +463,11 @@ func (a userRemoteLinksBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userRemoteLinksBelongsToUserTx) Unscoped() *userRemoteLinksBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userRemoteLinksDo struct{ gen.DO } type userRemoteLinksDo struct{ gen.DO }
type IUserRemoteLinksDo interface { type IUserRemoteLinksDo interface {
@ -511,6 +525,8 @@ type IUserRemoteLinksDo interface {
FirstOrCreate() (*models.UserRemoteLinks, error) FirstOrCreate() (*models.UserRemoteLinks, error)
FindByPage(offset int, limit int) (result []*models.UserRemoteLinks, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserRemoteLinks, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserRemoteLinksDo Returning(value interface{}, columns ...string) IUserRemoteLinksDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -259,11 +260,14 @@ func (u *userToBeing) fillFieldMap() {
func (u userToBeing) clone(db *gorm.DB) userToBeing { func (u userToBeing) clone(db *gorm.DB) userToBeing {
u.userToBeingDo.ReplaceConnPool(db.Statement.ConnPool) u.userToBeingDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userToBeing) replaceDB(db *gorm.DB) userToBeing { func (u userToBeing) replaceDB(db *gorm.DB) userToBeing {
u.userToBeingDo.ReplaceDB(db) u.userToBeingDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -376,6 +380,11 @@ func (a userToBeingBelongsToUser) Model(m *models.UserToBeing) *userToBeingBelon
return &userToBeingBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userToBeingBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToBeingBelongsToUser) Unscoped() *userToBeingBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userToBeingBelongsToUserTx struct{ tx *gorm.Association } type userToBeingBelongsToUserTx struct{ tx *gorm.Association }
func (a userToBeingBelongsToUserTx) Find() (result *models.User, err error) { func (a userToBeingBelongsToUserTx) Find() (result *models.User, err error) {
@ -414,6 +423,11 @@ func (a userToBeingBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToBeingBelongsToUserTx) Unscoped() *userToBeingBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToBeingDo struct{ gen.DO } type userToBeingDo struct{ gen.DO }
type IUserToBeingDo interface { type IUserToBeingDo interface {
@ -471,6 +485,8 @@ type IUserToBeingDo interface {
FirstOrCreate() (*models.UserToBeing, error) FirstOrCreate() (*models.UserToBeing, error)
FindByPage(offset int, limit int) (result []*models.UserToBeing, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserToBeing, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserToBeingDo Returning(value interface{}, columns ...string) IUserToBeingDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -259,11 +260,14 @@ func (u *userToPronoun) fillFieldMap() {
func (u userToPronoun) clone(db *gorm.DB) userToPronoun { func (u userToPronoun) clone(db *gorm.DB) userToPronoun {
u.userToPronounDo.ReplaceConnPool(db.Statement.ConnPool) u.userToPronounDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userToPronoun) replaceDB(db *gorm.DB) userToPronoun { func (u userToPronoun) replaceDB(db *gorm.DB) userToPronoun {
u.userToPronounDo.ReplaceDB(db) u.userToPronounDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -376,6 +380,11 @@ func (a userToPronounBelongsToUser) Model(m *models.UserToPronoun) *userToPronou
return &userToPronounBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userToPronounBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToPronounBelongsToUser) Unscoped() *userToPronounBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userToPronounBelongsToUserTx struct{ tx *gorm.Association } type userToPronounBelongsToUserTx struct{ tx *gorm.Association }
func (a userToPronounBelongsToUserTx) Find() (result *models.User, err error) { func (a userToPronounBelongsToUserTx) Find() (result *models.User, err error) {
@ -414,6 +423,11 @@ func (a userToPronounBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToPronounBelongsToUserTx) Unscoped() *userToPronounBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToPronounDo struct{ gen.DO } type userToPronounDo struct{ gen.DO }
type IUserToPronounDo interface { type IUserToPronounDo interface {
@ -471,6 +485,8 @@ type IUserToPronounDo interface {
FirstOrCreate() (*models.UserToPronoun, error) FirstOrCreate() (*models.UserToPronoun, error)
FindByPage(offset int, limit int) (result []*models.UserToPronoun, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserToPronoun, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserToPronounDo Returning(value interface{}, columns ...string) IUserToPronounDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -267,11 +268,17 @@ func (u *userToRole) fillFieldMap() {
func (u userToRole) clone(db *gorm.DB) userToRole { func (u userToRole) clone(db *gorm.DB) userToRole {
u.userToRoleDo.ReplaceConnPool(db.Statement.ConnPool) u.userToRoleDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
u.Role.db = db.Session(&gorm.Session{Initialized: true})
u.Role.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userToRole) replaceDB(db *gorm.DB) userToRole { func (u userToRole) replaceDB(db *gorm.DB) userToRole {
u.userToRoleDo.ReplaceDB(db) u.userToRoleDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
u.Role.db = db.Session(&gorm.Session{})
return u return u
} }
@ -384,6 +391,11 @@ func (a userToRoleBelongsToUser) Model(m *models.UserToRole) *userToRoleBelongsT
return &userToRoleBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userToRoleBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToRoleBelongsToUser) Unscoped() *userToRoleBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userToRoleBelongsToUserTx struct{ tx *gorm.Association } type userToRoleBelongsToUserTx struct{ tx *gorm.Association }
func (a userToRoleBelongsToUserTx) Find() (result *models.User, err error) { func (a userToRoleBelongsToUserTx) Find() (result *models.User, err error) {
@ -422,6 +434,11 @@ func (a userToRoleBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToRoleBelongsToUserTx) Unscoped() *userToRoleBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToRoleBelongsToRole struct { type userToRoleBelongsToRole struct {
db *gorm.DB db *gorm.DB
@ -455,6 +472,11 @@ func (a userToRoleBelongsToRole) Model(m *models.UserToRole) *userToRoleBelongsT
return &userToRoleBelongsToRoleTx{a.db.Model(m).Association(a.Name())} return &userToRoleBelongsToRoleTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToRoleBelongsToRole) Unscoped() *userToRoleBelongsToRole {
a.db = a.db.Unscoped()
return &a
}
type userToRoleBelongsToRoleTx struct{ tx *gorm.Association } type userToRoleBelongsToRoleTx struct{ tx *gorm.Association }
func (a userToRoleBelongsToRoleTx) Find() (result *models.Role, err error) { func (a userToRoleBelongsToRoleTx) Find() (result *models.Role, err error) {
@ -493,6 +515,11 @@ func (a userToRoleBelongsToRoleTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToRoleBelongsToRoleTx) Unscoped() *userToRoleBelongsToRoleTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToRoleDo struct{ gen.DO } type userToRoleDo struct{ gen.DO }
type IUserToRoleDo interface { type IUserToRoleDo interface {
@ -550,6 +577,8 @@ type IUserToRoleDo interface {
FirstOrCreate() (*models.UserToRole, error) FirstOrCreate() (*models.UserToRole, error)
FindByPage(offset int, limit int) (result []*models.UserToRole, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserToRole, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserToRoleDo Returning(value interface{}, columns ...string) IUserToRoleDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -259,11 +260,14 @@ func (u *userToTag) fillFieldMap() {
func (u userToTag) clone(db *gorm.DB) userToTag { func (u userToTag) clone(db *gorm.DB) userToTag {
u.userToTagDo.ReplaceConnPool(db.Statement.ConnPool) u.userToTagDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userToTag) replaceDB(db *gorm.DB) userToTag { func (u userToTag) replaceDB(db *gorm.DB) userToTag {
u.userToTagDo.ReplaceDB(db) u.userToTagDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
return u return u
} }
@ -376,6 +380,11 @@ func (a userToTagBelongsToUser) Model(m *models.UserToTag) *userToTagBelongsToUs
return &userToTagBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userToTagBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToTagBelongsToUser) Unscoped() *userToTagBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userToTagBelongsToUserTx struct{ tx *gorm.Association } type userToTagBelongsToUserTx struct{ tx *gorm.Association }
func (a userToTagBelongsToUserTx) Find() (result *models.User, err error) { func (a userToTagBelongsToUserTx) Find() (result *models.User, err error) {
@ -414,6 +423,11 @@ func (a userToTagBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToTagBelongsToUserTx) Unscoped() *userToTagBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToTagDo struct{ gen.DO } type userToTagDo struct{ gen.DO }
type IUserToTagDo interface { type IUserToTagDo interface {
@ -471,6 +485,8 @@ type IUserToTagDo interface {
FirstOrCreate() (*models.UserToTag, error) FirstOrCreate() (*models.UserToTag, error)
FindByPage(offset int, limit int) (result []*models.UserToTag, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserToTag, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserToTagDo Returning(value interface{}, columns ...string) IUserToTagDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
"gorm.io/gorm" "gorm.io/gorm"
@ -271,11 +272,17 @@ func (u *userToUserRelation) fillFieldMap() {
func (u userToUserRelation) clone(db *gorm.DB) userToUserRelation { func (u userToUserRelation) clone(db *gorm.DB) userToUserRelation {
u.userToUserRelationDo.ReplaceConnPool(db.Statement.ConnPool) u.userToUserRelationDo.ReplaceConnPool(db.Statement.ConnPool)
u.User.db = db.Session(&gorm.Session{Initialized: true})
u.User.db.Statement.ConnPool = db.Statement.ConnPool
u.TargetUser.db = db.Session(&gorm.Session{Initialized: true})
u.TargetUser.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u userToUserRelation) replaceDB(db *gorm.DB) userToUserRelation { func (u userToUserRelation) replaceDB(db *gorm.DB) userToUserRelation {
u.userToUserRelationDo.ReplaceDB(db) u.userToUserRelationDo.ReplaceDB(db)
u.User.db = db.Session(&gorm.Session{})
u.TargetUser.db = db.Session(&gorm.Session{})
return u return u
} }
@ -388,6 +395,11 @@ func (a userToUserRelationBelongsToUser) Model(m *models.UserToUserRelation) *us
return &userToUserRelationBelongsToUserTx{a.db.Model(m).Association(a.Name())} return &userToUserRelationBelongsToUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToUserRelationBelongsToUser) Unscoped() *userToUserRelationBelongsToUser {
a.db = a.db.Unscoped()
return &a
}
type userToUserRelationBelongsToUserTx struct{ tx *gorm.Association } type userToUserRelationBelongsToUserTx struct{ tx *gorm.Association }
func (a userToUserRelationBelongsToUserTx) Find() (result *models.User, err error) { func (a userToUserRelationBelongsToUserTx) Find() (result *models.User, err error) {
@ -426,6 +438,11 @@ func (a userToUserRelationBelongsToUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToUserRelationBelongsToUserTx) Unscoped() *userToUserRelationBelongsToUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToUserRelationBelongsToTargetUser struct { type userToUserRelationBelongsToTargetUser struct {
db *gorm.DB db *gorm.DB
@ -459,6 +476,11 @@ func (a userToUserRelationBelongsToTargetUser) Model(m *models.UserToUserRelatio
return &userToUserRelationBelongsToTargetUserTx{a.db.Model(m).Association(a.Name())} return &userToUserRelationBelongsToTargetUserTx{a.db.Model(m).Association(a.Name())}
} }
func (a userToUserRelationBelongsToTargetUser) Unscoped() *userToUserRelationBelongsToTargetUser {
a.db = a.db.Unscoped()
return &a
}
type userToUserRelationBelongsToTargetUserTx struct{ tx *gorm.Association } type userToUserRelationBelongsToTargetUserTx struct{ tx *gorm.Association }
func (a userToUserRelationBelongsToTargetUserTx) Find() (result *models.User, err error) { func (a userToUserRelationBelongsToTargetUserTx) Find() (result *models.User, err error) {
@ -497,6 +519,11 @@ func (a userToUserRelationBelongsToTargetUserTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userToUserRelationBelongsToTargetUserTx) Unscoped() *userToUserRelationBelongsToTargetUserTx {
a.tx = a.tx.Unscoped()
return &a
}
type userToUserRelationDo struct{ gen.DO } type userToUserRelationDo struct{ gen.DO }
type IUserToUserRelationDo interface { type IUserToUserRelationDo interface {
@ -554,6 +581,8 @@ type IUserToUserRelationDo interface {
FirstOrCreate() (*models.UserToUserRelation, error) FirstOrCreate() (*models.UserToUserRelation, error)
FindByPage(offset int, limit int) (result []*models.UserToUserRelation, count int64, err error) FindByPage(offset int, limit int) (result []*models.UserToUserRelation, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserToUserRelationDo Returning(value interface{}, columns ...string) IUserToUserRelationDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -6,6 +6,7 @@ package dbgen
import ( import (
"context" "context"
"database/sql"
"strings" "strings"
"git.mstar.dev/mstar/linstrom/storage-new/models" "git.mstar.dev/mstar/linstrom/storage-new/models"
@ -501,11 +502,47 @@ func (u *user) fillFieldMap() {
func (u user) clone(db *gorm.DB) user { func (u user) clone(db *gorm.DB) user {
u.userDo.ReplaceConnPool(db.Statement.ConnPool) u.userDo.ReplaceConnPool(db.Statement.ConnPool)
u.RemoteInfo.db = db.Session(&gorm.Session{Initialized: true})
u.RemoteInfo.db.Statement.ConnPool = db.Statement.ConnPool
u.InfoFields.db = db.Session(&gorm.Session{Initialized: true})
u.InfoFields.db.Statement.ConnPool = db.Statement.ConnPool
u.BeingTypes.db = db.Session(&gorm.Session{Initialized: true})
u.BeingTypes.db.Statement.ConnPool = db.Statement.ConnPool
u.Tags.db = db.Session(&gorm.Session{Initialized: true})
u.Tags.db.Statement.ConnPool = db.Statement.ConnPool
u.Relations.db = db.Session(&gorm.Session{Initialized: true})
u.Relations.db.Statement.ConnPool = db.Statement.ConnPool
u.Pronouns.db = db.Session(&gorm.Session{Initialized: true})
u.Pronouns.db.Statement.ConnPool = db.Statement.ConnPool
u.Roles.db = db.Session(&gorm.Session{Initialized: true})
u.Roles.db.Statement.ConnPool = db.Statement.ConnPool
u.AuthMethods.db = db.Session(&gorm.Session{Initialized: true})
u.AuthMethods.db.Statement.ConnPool = db.Statement.ConnPool
u.Server.db = db.Session(&gorm.Session{Initialized: true})
u.Server.db.Statement.ConnPool = db.Statement.ConnPool
u.Icon.db = db.Session(&gorm.Session{Initialized: true})
u.Icon.db.Statement.ConnPool = db.Statement.ConnPool
u.Background.db = db.Session(&gorm.Session{Initialized: true})
u.Background.db.Statement.ConnPool = db.Statement.ConnPool
u.Banner.db = db.Session(&gorm.Session{Initialized: true})
u.Banner.db.Statement.ConnPool = db.Statement.ConnPool
return u return u
} }
func (u user) replaceDB(db *gorm.DB) user { func (u user) replaceDB(db *gorm.DB) user {
u.userDo.ReplaceDB(db) u.userDo.ReplaceDB(db)
u.RemoteInfo.db = db.Session(&gorm.Session{})
u.InfoFields.db = db.Session(&gorm.Session{})
u.BeingTypes.db = db.Session(&gorm.Session{})
u.Tags.db = db.Session(&gorm.Session{})
u.Relations.db = db.Session(&gorm.Session{})
u.Pronouns.db = db.Session(&gorm.Session{})
u.Roles.db = db.Session(&gorm.Session{})
u.AuthMethods.db = db.Session(&gorm.Session{})
u.Server.db = db.Session(&gorm.Session{})
u.Icon.db = db.Session(&gorm.Session{})
u.Background.db = db.Session(&gorm.Session{})
u.Banner.db = db.Session(&gorm.Session{})
return u return u
} }
@ -618,6 +655,11 @@ func (a userHasOneRemoteInfo) Model(m *models.User) *userHasOneRemoteInfoTx {
return &userHasOneRemoteInfoTx{a.db.Model(m).Association(a.Name())} return &userHasOneRemoteInfoTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasOneRemoteInfo) Unscoped() *userHasOneRemoteInfo {
a.db = a.db.Unscoped()
return &a
}
type userHasOneRemoteInfoTx struct{ tx *gorm.Association } type userHasOneRemoteInfoTx struct{ tx *gorm.Association }
func (a userHasOneRemoteInfoTx) Find() (result *models.UserRemoteLinks, err error) { func (a userHasOneRemoteInfoTx) Find() (result *models.UserRemoteLinks, err error) {
@ -656,6 +698,11 @@ func (a userHasOneRemoteInfoTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasOneRemoteInfoTx) Unscoped() *userHasOneRemoteInfoTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyInfoFields struct { type userHasManyInfoFields struct {
db *gorm.DB db *gorm.DB
@ -689,6 +736,11 @@ func (a userHasManyInfoFields) Model(m *models.User) *userHasManyInfoFieldsTx {
return &userHasManyInfoFieldsTx{a.db.Model(m).Association(a.Name())} return &userHasManyInfoFieldsTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyInfoFields) Unscoped() *userHasManyInfoFields {
a.db = a.db.Unscoped()
return &a
}
type userHasManyInfoFieldsTx struct{ tx *gorm.Association } type userHasManyInfoFieldsTx struct{ tx *gorm.Association }
func (a userHasManyInfoFieldsTx) Find() (result []*models.UserInfoField, err error) { func (a userHasManyInfoFieldsTx) Find() (result []*models.UserInfoField, err error) {
@ -727,6 +779,11 @@ func (a userHasManyInfoFieldsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyInfoFieldsTx) Unscoped() *userHasManyInfoFieldsTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyBeingTypes struct { type userHasManyBeingTypes struct {
db *gorm.DB db *gorm.DB
@ -760,6 +817,11 @@ func (a userHasManyBeingTypes) Model(m *models.User) *userHasManyBeingTypesTx {
return &userHasManyBeingTypesTx{a.db.Model(m).Association(a.Name())} return &userHasManyBeingTypesTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyBeingTypes) Unscoped() *userHasManyBeingTypes {
a.db = a.db.Unscoped()
return &a
}
type userHasManyBeingTypesTx struct{ tx *gorm.Association } type userHasManyBeingTypesTx struct{ tx *gorm.Association }
func (a userHasManyBeingTypesTx) Find() (result []*models.UserToBeing, err error) { func (a userHasManyBeingTypesTx) Find() (result []*models.UserToBeing, err error) {
@ -798,6 +860,11 @@ func (a userHasManyBeingTypesTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyBeingTypesTx) Unscoped() *userHasManyBeingTypesTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyTags struct { type userHasManyTags struct {
db *gorm.DB db *gorm.DB
@ -831,6 +898,11 @@ func (a userHasManyTags) Model(m *models.User) *userHasManyTagsTx {
return &userHasManyTagsTx{a.db.Model(m).Association(a.Name())} return &userHasManyTagsTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyTags) Unscoped() *userHasManyTags {
a.db = a.db.Unscoped()
return &a
}
type userHasManyTagsTx struct{ tx *gorm.Association } type userHasManyTagsTx struct{ tx *gorm.Association }
func (a userHasManyTagsTx) Find() (result []*models.UserToTag, err error) { func (a userHasManyTagsTx) Find() (result []*models.UserToTag, err error) {
@ -869,6 +941,11 @@ func (a userHasManyTagsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyTagsTx) Unscoped() *userHasManyTagsTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyRelations struct { type userHasManyRelations struct {
db *gorm.DB db *gorm.DB
@ -902,6 +979,11 @@ func (a userHasManyRelations) Model(m *models.User) *userHasManyRelationsTx {
return &userHasManyRelationsTx{a.db.Model(m).Association(a.Name())} return &userHasManyRelationsTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyRelations) Unscoped() *userHasManyRelations {
a.db = a.db.Unscoped()
return &a
}
type userHasManyRelationsTx struct{ tx *gorm.Association } type userHasManyRelationsTx struct{ tx *gorm.Association }
func (a userHasManyRelationsTx) Find() (result []*models.UserToUserRelation, err error) { func (a userHasManyRelationsTx) Find() (result []*models.UserToUserRelation, err error) {
@ -940,6 +1022,11 @@ func (a userHasManyRelationsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyRelationsTx) Unscoped() *userHasManyRelationsTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyPronouns struct { type userHasManyPronouns struct {
db *gorm.DB db *gorm.DB
@ -973,6 +1060,11 @@ func (a userHasManyPronouns) Model(m *models.User) *userHasManyPronounsTx {
return &userHasManyPronounsTx{a.db.Model(m).Association(a.Name())} return &userHasManyPronounsTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyPronouns) Unscoped() *userHasManyPronouns {
a.db = a.db.Unscoped()
return &a
}
type userHasManyPronounsTx struct{ tx *gorm.Association } type userHasManyPronounsTx struct{ tx *gorm.Association }
func (a userHasManyPronounsTx) Find() (result []*models.UserToPronoun, err error) { func (a userHasManyPronounsTx) Find() (result []*models.UserToPronoun, err error) {
@ -1011,6 +1103,11 @@ func (a userHasManyPronounsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyPronounsTx) Unscoped() *userHasManyPronounsTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyRoles struct { type userHasManyRoles struct {
db *gorm.DB db *gorm.DB
@ -1044,6 +1141,11 @@ func (a userHasManyRoles) Model(m *models.User) *userHasManyRolesTx {
return &userHasManyRolesTx{a.db.Model(m).Association(a.Name())} return &userHasManyRolesTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyRoles) Unscoped() *userHasManyRoles {
a.db = a.db.Unscoped()
return &a
}
type userHasManyRolesTx struct{ tx *gorm.Association } type userHasManyRolesTx struct{ tx *gorm.Association }
func (a userHasManyRolesTx) Find() (result []*models.UserToRole, err error) { func (a userHasManyRolesTx) Find() (result []*models.UserToRole, err error) {
@ -1082,6 +1184,11 @@ func (a userHasManyRolesTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyRolesTx) Unscoped() *userHasManyRolesTx {
a.tx = a.tx.Unscoped()
return &a
}
type userHasManyAuthMethods struct { type userHasManyAuthMethods struct {
db *gorm.DB db *gorm.DB
@ -1115,6 +1222,11 @@ func (a userHasManyAuthMethods) Model(m *models.User) *userHasManyAuthMethodsTx
return &userHasManyAuthMethodsTx{a.db.Model(m).Association(a.Name())} return &userHasManyAuthMethodsTx{a.db.Model(m).Association(a.Name())}
} }
func (a userHasManyAuthMethods) Unscoped() *userHasManyAuthMethods {
a.db = a.db.Unscoped()
return &a
}
type userHasManyAuthMethodsTx struct{ tx *gorm.Association } type userHasManyAuthMethodsTx struct{ tx *gorm.Association }
func (a userHasManyAuthMethodsTx) Find() (result []*models.UserAuthMethod, err error) { func (a userHasManyAuthMethodsTx) Find() (result []*models.UserAuthMethod, err error) {
@ -1153,6 +1265,11 @@ func (a userHasManyAuthMethodsTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userHasManyAuthMethodsTx) Unscoped() *userHasManyAuthMethodsTx {
a.tx = a.tx.Unscoped()
return &a
}
type userBelongsToServer struct { type userBelongsToServer struct {
db *gorm.DB db *gorm.DB
@ -1186,6 +1303,11 @@ func (a userBelongsToServer) Model(m *models.User) *userBelongsToServerTx {
return &userBelongsToServerTx{a.db.Model(m).Association(a.Name())} return &userBelongsToServerTx{a.db.Model(m).Association(a.Name())}
} }
func (a userBelongsToServer) Unscoped() *userBelongsToServer {
a.db = a.db.Unscoped()
return &a
}
type userBelongsToServerTx struct{ tx *gorm.Association } type userBelongsToServerTx struct{ tx *gorm.Association }
func (a userBelongsToServerTx) Find() (result *models.RemoteServer, err error) { func (a userBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
@ -1224,6 +1346,11 @@ func (a userBelongsToServerTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userBelongsToServerTx) Unscoped() *userBelongsToServerTx {
a.tx = a.tx.Unscoped()
return &a
}
type userBelongsToIcon struct { type userBelongsToIcon struct {
db *gorm.DB db *gorm.DB
@ -1257,6 +1384,11 @@ func (a userBelongsToIcon) Model(m *models.User) *userBelongsToIconTx {
return &userBelongsToIconTx{a.db.Model(m).Association(a.Name())} return &userBelongsToIconTx{a.db.Model(m).Association(a.Name())}
} }
func (a userBelongsToIcon) Unscoped() *userBelongsToIcon {
a.db = a.db.Unscoped()
return &a
}
type userBelongsToIconTx struct{ tx *gorm.Association } type userBelongsToIconTx struct{ tx *gorm.Association }
func (a userBelongsToIconTx) Find() (result *models.MediaMetadata, err error) { func (a userBelongsToIconTx) Find() (result *models.MediaMetadata, err error) {
@ -1295,6 +1427,11 @@ func (a userBelongsToIconTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userBelongsToIconTx) Unscoped() *userBelongsToIconTx {
a.tx = a.tx.Unscoped()
return &a
}
type userBelongsToBackground struct { type userBelongsToBackground struct {
db *gorm.DB db *gorm.DB
@ -1328,6 +1465,11 @@ func (a userBelongsToBackground) Model(m *models.User) *userBelongsToBackgroundT
return &userBelongsToBackgroundTx{a.db.Model(m).Association(a.Name())} return &userBelongsToBackgroundTx{a.db.Model(m).Association(a.Name())}
} }
func (a userBelongsToBackground) Unscoped() *userBelongsToBackground {
a.db = a.db.Unscoped()
return &a
}
type userBelongsToBackgroundTx struct{ tx *gorm.Association } type userBelongsToBackgroundTx struct{ tx *gorm.Association }
func (a userBelongsToBackgroundTx) Find() (result *models.MediaMetadata, err error) { func (a userBelongsToBackgroundTx) Find() (result *models.MediaMetadata, err error) {
@ -1366,6 +1508,11 @@ func (a userBelongsToBackgroundTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userBelongsToBackgroundTx) Unscoped() *userBelongsToBackgroundTx {
a.tx = a.tx.Unscoped()
return &a
}
type userBelongsToBanner struct { type userBelongsToBanner struct {
db *gorm.DB db *gorm.DB
@ -1399,6 +1546,11 @@ func (a userBelongsToBanner) Model(m *models.User) *userBelongsToBannerTx {
return &userBelongsToBannerTx{a.db.Model(m).Association(a.Name())} return &userBelongsToBannerTx{a.db.Model(m).Association(a.Name())}
} }
func (a userBelongsToBanner) Unscoped() *userBelongsToBanner {
a.db = a.db.Unscoped()
return &a
}
type userBelongsToBannerTx struct{ tx *gorm.Association } type userBelongsToBannerTx struct{ tx *gorm.Association }
func (a userBelongsToBannerTx) Find() (result *models.MediaMetadata, err error) { func (a userBelongsToBannerTx) Find() (result *models.MediaMetadata, err error) {
@ -1437,6 +1589,11 @@ func (a userBelongsToBannerTx) Count() int64 {
return a.tx.Count() return a.tx.Count()
} }
func (a userBelongsToBannerTx) Unscoped() *userBelongsToBannerTx {
a.tx = a.tx.Unscoped()
return &a
}
type userDo struct{ gen.DO } type userDo struct{ gen.DO }
type IUserDo interface { type IUserDo interface {
@ -1494,6 +1651,8 @@ type IUserDo interface {
FirstOrCreate() (*models.User, error) FirstOrCreate() (*models.User, error)
FindByPage(offset int, limit int) (result []*models.User, count int64, err error) FindByPage(offset int, limit int) (result []*models.User, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (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) Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserDo Returning(value interface{}, columns ...string) IUserDo
UnderlyingDB() *gorm.DB UnderlyingDB() *gorm.DB

View file

@ -31,6 +31,12 @@ func Migrate(db *gorm.DB) error {
if err := createRemoteServerSoftwareType(db); err != nil { if err := createRemoteServerSoftwareType(db); err != nil {
return other.Error("storage", "Failed to create Server Software type", err) return other.Error("storage", "Failed to create Server Software type", err)
} }
if err := createActitiystreamsObjectType(db); err != nil {
return other.Error("storage", "Failed to create Activitystreams Object type", err)
}
if err := createActitiystreamsActivityType(db); err != nil {
return other.Error("storage", "Failed to create Activitystreams Activity type", err)
}
if err := migrateTypes(db); err != nil { if err := migrateTypes(db); err != nil {
return other.Error("storage", "Failed to automigrate data structs", err) return other.Error("storage", "Failed to automigrate data structs", err)
} }
@ -87,6 +93,39 @@ func createRemoteServerSoftwareType(db *gorm.DB) error {
) )
} }
func createActitiystreamsObjectType(db *gorm.DB) error {
return migrateEnum(
db,
"activitystreams_object_type",
sliceutils.Map(
models.AllActivitystreamsObjectTypes,
func(t models.ActivitystreamsObjectType) string { return string(t) },
),
)
}
func createActitiystreamsActivityType(db *gorm.DB) error {
return migrateEnum(
db,
"activitystreams_activity_type",
sliceutils.Map(
models.AllActivitystreamsActivityTypes,
func(t models.ActivitystreamsActivityType) string { return string(t) },
),
)
}
func createActitiystreamsActivityTargetType(db *gorm.DB) error {
return migrateEnum(
db,
"activitystreams_activity_target_type",
sliceutils.Map(
models.AllActivitystreamsActivityTargetTypes,
func(t models.ActivitystreamsActivityTargetType) string { return string(t) },
),
)
}
// Helper function for ensuring the existence of an enum with the given values // Helper function for ensuring the existence of an enum with the given values
func migrateEnum(db *gorm.DB, name string, values []string) error { func migrateEnum(db *gorm.DB, name string, values []string) error {
if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil { if err := db.Exec("DROP TYPE IF EXISTS " + name + " CASCADE;").Error; err != nil {

View file

@ -2,10 +2,12 @@ package models
// A list of all models stored in the database // A list of all models stored in the database
var AllTypes = []any{ var AllTypes = []any{
&ActivitystreamsActivity{},
&Emote{}, &Emote{},
&Feed{}, &Feed{},
&MediaMetadata{}, &MediaMetadata{},
&Note{}, &Note{},
&NoteEdit{},
&NoteToAttachment{}, &NoteToAttachment{},
&NoteToBoost{}, &NoteToBoost{},
&NoteToEmote{}, &NoteToEmote{},

View file

@ -0,0 +1,32 @@
package models
import "database/sql/driver"
type ActivitystreamsActivityTargetType uint32
const (
ActivitystreamsActivityTargetUnknown ActivitystreamsActivityTargetType = iota
ActivitystreamsActivityTargetActivity
ActivitystreamsActivityTargetNote
ActivitystreamsActivityTargetUser
ActivitystreamsActivityTargetBoost
ActivitystreamsActivityTargetReaction
)
func (n *ActivitystreamsActivityTargetType) Value() (driver.Value, error) {
return n, nil
}
func (ct *ActivitystreamsActivityTargetType) Scan(value any) error {
*ct = ActivitystreamsActivityTargetType(value.(uint32))
return nil
}
var AllActivitystreamsActivityTargetTypes = []ActivitystreamsActivityTargetType{
ActivitystreamsActivityTargetUnknown,
ActivitystreamsActivityTargetActivity,
ActivitystreamsActivityTargetNote,
ActivitystreamsActivityTargetUser,
ActivitystreamsActivityTargetBoost,
ActivitystreamsActivityTargetReaction,
}

View file

@ -0,0 +1,7 @@
package models
type ActivitystreamsActivity struct {
Type string `gorm:"type:activitystreams_activity_type"`
ObjectId string
ObjectType uint32 // Target type: ActivitystreamsActivityTargetType
}

View file

@ -0,0 +1,78 @@
package models
import "database/sql/driver"
type ActivitystreamsActivityType string
const (
ActivityUnknown = ActivitystreamsActivityType("unknown")
ActivityAccept = ActivitystreamsActivityType("accept")
ActivityAdd = ActivitystreamsActivityType("add")
ActivityAnnounce = ActivitystreamsActivityType("announce")
ActivityArrive = ActivitystreamsActivityType("arrive")
ActivityBlock = ActivitystreamsActivityType("block")
ActivityCreate = ActivitystreamsActivityType("create")
ActivityDelete = ActivitystreamsActivityType("delete")
ActivityDislike = ActivitystreamsActivityType("dislike")
ActivityFlag = ActivitystreamsActivityType("flag")
ActivityFollow = ActivitystreamsActivityType("follow")
ActivityIgnore = ActivitystreamsActivityType("ignore")
ActivityInvite = ActivitystreamsActivityType("invite")
ActivityJoin = ActivitystreamsActivityType("join")
ActivityLeave = ActivitystreamsActivityType("leave")
ActivityLike = ActivitystreamsActivityType("like")
ActivityListen = ActivitystreamsActivityType("listen")
ActivityMove = ActivitystreamsActivityType("move")
ActivityOffer = ActivitystreamsActivityType("offer")
ActivityQuestion = ActivitystreamsActivityType("question")
ActivityRead = ActivitystreamsActivityType("read")
ActivityReject = ActivitystreamsActivityType("reject")
ActivityRemove = ActivitystreamsActivityType("remove")
ActivityTentativeAccept = ActivitystreamsActivityType("tentative-accept")
ActivityTentativeReject = ActivitystreamsActivityType("tentative-reject")
ActivityTravel = ActivitystreamsActivityType("travel")
ActivityUndo = ActivitystreamsActivityType("undo")
ActivityUpdate = ActivitystreamsActivityType("update")
ActivityView = ActivitystreamsActivityType("view")
)
var AllActivitystreamsActivityTypes = []ActivitystreamsActivityType{
ActivityUnknown,
ActivityAccept,
ActivityAdd,
ActivityAnnounce,
ActivityArrive,
ActivityBlock,
ActivityCreate,
ActivityDelete,
ActivityDislike,
ActivityFlag,
ActivityFollow,
ActivityIgnore,
ActivityInvite,
ActivityJoin,
ActivityLeave,
ActivityLike,
ActivityListen,
ActivityMove,
ActivityOffer,
ActivityQuestion,
ActivityRead,
ActivityReject,
ActivityRemove,
ActivityTentativeAccept,
ActivityTentativeReject,
ActivityTravel,
ActivityUndo,
ActivityUpdate,
ActivityView,
}
func (r *ActivitystreamsActivityType) Value() (driver.Value, error) {
return r, nil
}
func (ct *ActivitystreamsActivityType) Scan(value any) error {
*ct = ActivitystreamsActivityType(value.(string))
return nil
}

View file

@ -0,0 +1,6 @@
package models
// Not sure an extra table is even needed for AS objects
// since endpoints get the ID from the url anyway
type ActivitystreamsObject struct {
}

View file

@ -0,0 +1,46 @@
package models
import "database/sql/driver"
type ActivitystreamsObjectType string
const (
ObjectTypeUnknown = ActivitystreamsObjectType("unknown")
ObjectTypeArticle = ActivitystreamsObjectType("article")
ObjectTypeAudio = ActivitystreamsObjectType("audio")
ObjectTypeDocument = ActivitystreamsObjectType("document")
ObjectTypeEvent = ActivitystreamsObjectType("event")
ObjectTypeImage = ActivitystreamsObjectType("image")
ObjectTypeNote = ActivitystreamsObjectType("note")
ObjectTypePage = ActivitystreamsObjectType("page")
ObjectTypePlace = ActivitystreamsObjectType("place")
ObjectTypeProfile = ActivitystreamsObjectType("profile")
ObjectTypeRelationship = ActivitystreamsObjectType("relationsjip")
ObjectTypeTombstone = ActivitystreamsObjectType("tombstone")
ObjectTypeVideo = ActivitystreamsObjectType("video")
)
var AllActivitystreamsObjectTypes = []ActivitystreamsObjectType{
ObjectTypeUnknown,
ObjectTypeArticle,
ObjectTypeAudio,
ObjectTypeDocument,
ObjectTypeEvent,
ObjectTypeImage,
ObjectTypeNote,
ObjectTypePage,
ObjectTypePlace,
ObjectTypeProfile,
ObjectTypeRelationship,
ObjectTypeTombstone,
ObjectTypeVideo,
}
func (r *ActivitystreamsObjectType) Value() (driver.Value, error) {
return r, nil
}
func (ct *ActivitystreamsObjectType) Scan(value any) error {
*ct = ActivitystreamsObjectType(value.(string))
return nil
}

View file

@ -29,10 +29,11 @@ type Note struct {
Origin RemoteServer Origin RemoteServer
OriginId uint OriginId uint
AttachmentRelations []NoteToAttachment `gorm:"foreignKey:NoteId"` // Attachments added on to this note AttachmentRelations []NoteToAttachment `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Attachments added on to this note
EmoteRelations []NoteToEmote `gorm:"foreignKey:NoteId"` // Emotes used in this note EmoteRelations []NoteToEmote `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Emotes used in this note
PingRelations []NoteToPing `gorm:"foreignKey:NoteId"` // Pings/mentions this note performs PingRelations []NoteToPing `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Pings/mentions this note performs
Tags []NoteTag `gorm:"foreignKey:NoteId"` // Tags this note contains Tags []NoteTag `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // Tags this note contains
Edits []NoteEdit `gorm:"foreignKey:NoteId;constraint:OnDelete:CASCADE"` // All edits done to this note
} }
type INote interface { type INote interface {

View file

@ -0,0 +1,45 @@
package models
import (
"time"
"gorm.io/gen"
)
// NoteEdit denotes one edit done to one known note.
// The table is (within this application) append only
// (Except for the case where a note is hard deleted,
// where the edits for it also need to be deleted.
// Direct access to the db also circumvents this).
// Every edit will append one entry per edited field, denoting
// the field and how it was changed, in chronological order
type NoteEdit struct {
Note Note
NoteId string `gorm:"primaryKey;autoIncrement:false;<-:create"`
EditNr uint64 `gorm:"primaryKey;autoIncrement:false;<-:create"`
CreatedAt time.Time `gorm:"<-:create"`
Before string `gorm:"<-:create"`
After string `gorm:"<-:create"`
Field string `gorm:"<-:create"` // What was edited
}
type INoteEdit interface {
// Append a new edit to a note
//
// INSERT INTO @@table
// (note_id, edit_nr, created_at, before, after, field)
// VALUES (
// @note_id,
// (SELECT COUNT(*) FROM @@table WHERE note_id = @noteId)+1,
// NOW(),
// @before,
// @after,
// @field
// )
AppendEdit(noteId, before, after, field string) error
// Find all edits for a field
//
// SELECT * FROM @@table WHERE note_id = @noteId AND field = @field
FindEditsForField(noteId, field string) ([]gen.T, error)
}