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

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