chore(storage): run gorm gen
This commit is contained in:
parent
3f5df241db
commit
427675f38e
22 changed files with 554 additions and 174 deletions
|
@ -35,6 +35,19 @@ func newAccessToken(db *gorm.DB, opts ...gen.DOOption) accessToken {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -245,6 +258,12 @@ type accessTokenBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -440,15 +459,15 @@ type IAccessTokenDo interface {
|
|||
GetTokenIfValid(token string) (result *models.AccessToken, err error)
|
||||
}
|
||||
|
||||
// Get the data for a token if it hasn't expired yet
|
||||
// Get the data for a token
|
||||
//
|
||||
// SELECT * FROM @@table WHERE token = @token AND expires_at < NOW() LIMIT 1
|
||||
// SELECT * FROM @@table WHERE token = @token
|
||||
func (a accessTokenDo) GetTokenIfValid(token string) (result *models.AccessToken, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, token)
|
||||
generateSQL.WriteString("SELECT * FROM access_tokens WHERE token = ? AND expires_at < NOW() LIMIT 1 ")
|
||||
generateSQL.WriteString("SELECT * FROM access_tokens WHERE token = ? ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = a.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
|
|
|
@ -38,6 +38,19 @@ func newFeed(db *gorm.DB, opts ...gen.DOOption) feed {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Owner", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -260,6 +273,12 @@ type feedBelongsToOwner struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -35,6 +35,19 @@ func newLoginProcessToken(db *gorm.DB, opts ...gen.DOOption) loginProcessToken {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -248,6 +261,12 @@ type loginProcessTokenBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func newMediaMetadata(db *gorm.DB, opts ...gen.DOOption) mediaMetadata {
|
|||
_mediaMetadata.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_mediaMetadata.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_mediaMetadata.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_mediaMetadata.OwnedById = field.NewString(tableName, "owned_by_id")
|
||||
_mediaMetadata.OwnedById = field.NewField(tableName, "owned_by_id")
|
||||
_mediaMetadata.Remote = field.NewBool(tableName, "remote")
|
||||
_mediaMetadata.Location = field.NewString(tableName, "location")
|
||||
_mediaMetadata.Type = field.NewString(tableName, "type")
|
||||
|
@ -51,7 +51,7 @@ type mediaMetadata struct {
|
|||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
OwnedById field.String
|
||||
OwnedById field.Field
|
||||
Remote field.Bool
|
||||
Location field.String
|
||||
Type field.String
|
||||
|
@ -78,7 +78,7 @@ func (m *mediaMetadata) updateTableName(table string) *mediaMetadata {
|
|||
m.CreatedAt = field.NewTime(table, "created_at")
|
||||
m.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
m.DeletedAt = field.NewField(table, "deleted_at")
|
||||
m.OwnedById = field.NewString(table, "owned_by_id")
|
||||
m.OwnedById = field.NewField(table, "owned_by_id")
|
||||
m.Remote = field.NewBool(table, "remote")
|
||||
m.Location = field.NewString(table, "location")
|
||||
m.Type = field.NewString(table, "type")
|
||||
|
|
|
@ -35,6 +35,12 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -100,6 +106,19 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -269,9 +288,6 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -288,9 +304,6 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -301,16 +314,8 @@ func newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -422,6 +427,12 @@ type noteTagBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -507,9 +518,6 @@ type noteTagBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -100,6 +106,19 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -269,9 +288,6 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -288,9 +304,6 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -301,16 +314,8 @@ func newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -430,6 +435,12 @@ type noteToAttachmentBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -515,9 +526,6 @@ type noteToAttachmentBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,19 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -213,9 +226,6 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -232,9 +242,6 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -245,16 +252,8 @@ func newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -369,6 +368,12 @@ type noteToBoostBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -528,9 +533,6 @@ type noteToBoostBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -100,6 +106,19 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -269,9 +288,6 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -288,9 +304,6 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -301,16 +314,8 @@ func newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -430,6 +435,12 @@ type noteToEmoteBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -515,9 +526,6 @@ type noteToEmoteBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -100,6 +106,19 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -269,9 +288,6 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -288,9 +304,6 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -301,16 +314,8 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -422,6 +427,12 @@ type noteToFeedBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -507,9 +518,6 @@ type noteToFeedBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -100,6 +106,19 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -269,9 +288,6 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -288,9 +304,6 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -301,16 +314,8 @@ func newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -430,6 +435,12 @@ type noteToPingBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -515,9 +526,6 @@ type noteToPingBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,12 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
field.RelationField
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -125,9 +131,6 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +153,12 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
RelationField: field.NewRelation("AttachmentRelations.Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -215,6 +224,19 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -368,9 +390,6 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -387,9 +406,6 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -400,16 +416,8 @@ func newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -588,6 +596,12 @@ type noteHasManyAttachmentRelations struct {
|
|||
field.RelationField
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -667,9 +681,6 @@ type noteHasManyAttachmentRelations struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,19 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("ForUser", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("ForUser.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("ForUser.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -219,9 +232,6 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -238,9 +248,6 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("SourceNote.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -251,16 +258,8 @@ func newNotification(db *gorm.DB, opts ...gen.DOOption) notification {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("SourceNote.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("SourceNote.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -398,6 +397,12 @@ type notificationBelongsToForUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -557,9 +562,6 @@ type notificationBelongsToSourceNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,12 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -104,6 +110,19 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -273,9 +292,6 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
|
@ -292,9 +308,6 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
|
@ -305,16 +318,8 @@ func newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
|||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -454,6 +459,12 @@ type reactionBelongsToNote struct {
|
|||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -539,9 +550,6 @@ type reactionBelongsToNote struct {
|
|||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,19 @@ func newUserAuthMethod(db *gorm.DB, opts ...gen.DOOption) userAuthMethod {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -260,6 +273,12 @@ type userAuthMethodBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -39,6 +39,19 @@ func newUserInfoField(db *gorm.DB, opts ...gen.DOOption) userInfoField {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -264,6 +277,12 @@ type userInfoFieldBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -43,6 +43,19 @@ func newUserRemoteLinks(db *gorm.DB, opts ...gen.DOOption) userRemoteLinks {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -280,6 +293,12 @@ type userRemoteLinksBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -33,6 +33,19 @@ func newUserToBeing(db *gorm.DB, opts ...gen.DOOption) userToBeing {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -240,6 +253,12 @@ type userToBeingBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -28,11 +28,24 @@ func newUserToPronoun(db *gorm.DB, opts ...gen.DOOption) userToPronoun {
|
|||
_userToPronoun.ALL = field.NewAsterisk(tableName)
|
||||
_userToPronoun.ID = field.NewUint64(tableName, "id")
|
||||
_userToPronoun.UserId = field.NewString(tableName, "user_id")
|
||||
_userToPronoun.Pronoung = field.NewString(tableName, "pronoung")
|
||||
_userToPronoun.Pronoun = field.NewString(tableName, "pronoun")
|
||||
_userToPronoun.User = userToPronounBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -178,11 +191,11 @@ func newUserToPronoun(db *gorm.DB, opts ...gen.DOOption) userToPronoun {
|
|||
type userToPronoun struct {
|
||||
userToPronounDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
UserId field.String
|
||||
Pronoung field.String
|
||||
User userToPronounBelongsToUser
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
UserId field.String
|
||||
Pronoun field.String
|
||||
User userToPronounBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
@ -201,7 +214,7 @@ func (u *userToPronoun) updateTableName(table string) *userToPronoun {
|
|||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewUint64(table, "id")
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.Pronoung = field.NewString(table, "pronoung")
|
||||
u.Pronoun = field.NewString(table, "pronoun")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
|
@ -221,7 +234,7 @@ func (u *userToPronoun) fillFieldMap() {
|
|||
u.fieldMap = make(map[string]field.Expr, 4)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["pronoung"] = u.Pronoung
|
||||
u.fieldMap["pronoun"] = u.Pronoun
|
||||
|
||||
}
|
||||
|
||||
|
@ -240,6 +253,12 @@ type userToPronounBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -33,6 +33,19 @@ func newUserToRole(db *gorm.DB, opts ...gen.DOOption) userToRole {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -248,6 +261,12 @@ type userToRoleBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -33,6 +33,19 @@ func newUserToTag(db *gorm.DB, opts ...gen.DOOption) userToTag {
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -240,6 +253,12 @@ type userToTagBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -34,6 +34,19 @@ func newUserToUserRelation(db *gorm.DB, opts ...gen.DOOption) userToUserRelation
|
|||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -252,6 +265,12 @@ type userToUserRelationBelongsToUser struct {
|
|||
|
||||
field.RelationField
|
||||
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
_user.DisplayName = field.NewString(tableName, "display_name")
|
||||
_user.Description = field.NewString(tableName, "description")
|
||||
_user.IsBot = field.NewBool(tableName, "is_bot")
|
||||
_user.IconId = field.NewString(tableName, "icon_id")
|
||||
_user.IconId = field.NewField(tableName, "icon_id")
|
||||
_user.BackgroundId = field.NewField(tableName, "background_id")
|
||||
_user.BannerId = field.NewField(tableName, "banner_id")
|
||||
_user.Indexable = field.NewBool(tableName, "indexable")
|
||||
|
@ -47,12 +47,19 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
_user.Verified = field.NewBool(tableName, "verified")
|
||||
_user.PasskeyId = field.NewBytes(tableName, "passkey_id")
|
||||
_user.FinishedRegistration = field.NewBool(tableName, "finished_registration")
|
||||
_user.PrivateKey = field.NewBytes(tableName, "private_key")
|
||||
_user.RemoteInfo = userHasOneRemoteInfo{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("RemoteInfo", "models.UserRemoteLinks"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -115,6 +122,19 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("RemoteInfo.User", "models.User"),
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("RemoteInfo.User.Server", "models.RemoteServer"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("RemoteInfo.User.Server.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
|
@ -287,6 +307,12 @@ func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|||
RelationField: field.NewRelation("AuthMethods", "models.UserAuthMethod"),
|
||||
}
|
||||
|
||||
_user.Server = userBelongsToServer{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Server", "models.RemoteServer"),
|
||||
}
|
||||
|
||||
_user.Icon = userBelongsToIcon{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
|
@ -323,7 +349,7 @@ type user struct {
|
|||
DisplayName field.String
|
||||
Description field.String
|
||||
IsBot field.Bool
|
||||
IconId field.String
|
||||
IconId field.Field
|
||||
BackgroundId field.Field
|
||||
BannerId field.Field
|
||||
Indexable field.Bool
|
||||
|
@ -334,6 +360,7 @@ type user struct {
|
|||
Verified field.Bool
|
||||
PasskeyId field.Bytes
|
||||
FinishedRegistration field.Bool
|
||||
PrivateKey field.Bytes
|
||||
RemoteInfo userHasOneRemoteInfo
|
||||
|
||||
InfoFields userHasManyInfoFields
|
||||
|
@ -350,6 +377,8 @@ type user struct {
|
|||
|
||||
AuthMethods userHasManyAuthMethods
|
||||
|
||||
Server userBelongsToServer
|
||||
|
||||
Icon userBelongsToIcon
|
||||
|
||||
Background userBelongsToBackground
|
||||
|
@ -380,7 +409,7 @@ func (u *user) updateTableName(table string) *user {
|
|||
u.DisplayName = field.NewString(table, "display_name")
|
||||
u.Description = field.NewString(table, "description")
|
||||
u.IsBot = field.NewBool(table, "is_bot")
|
||||
u.IconId = field.NewString(table, "icon_id")
|
||||
u.IconId = field.NewField(table, "icon_id")
|
||||
u.BackgroundId = field.NewField(table, "background_id")
|
||||
u.BannerId = field.NewField(table, "banner_id")
|
||||
u.Indexable = field.NewBool(table, "indexable")
|
||||
|
@ -391,6 +420,7 @@ func (u *user) updateTableName(table string) *user {
|
|||
u.Verified = field.NewBool(table, "verified")
|
||||
u.PasskeyId = field.NewBytes(table, "passkey_id")
|
||||
u.FinishedRegistration = field.NewBool(table, "finished_registration")
|
||||
u.PrivateKey = field.NewBytes(table, "private_key")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
|
@ -407,7 +437,7 @@ func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||
}
|
||||
|
||||
func (u *user) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 31)
|
||||
u.fieldMap = make(map[string]field.Expr, 33)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["username"] = u.Username
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
|
@ -428,6 +458,7 @@ func (u *user) fillFieldMap() {
|
|||
u.fieldMap["verified"] = u.Verified
|
||||
u.fieldMap["passkey_id"] = u.PasskeyId
|
||||
u.fieldMap["finished_registration"] = u.FinishedRegistration
|
||||
u.fieldMap["private_key"] = u.PrivateKey
|
||||
|
||||
}
|
||||
|
||||
|
@ -448,6 +479,12 @@ type userHasOneRemoteInfo struct {
|
|||
|
||||
User struct {
|
||||
field.RelationField
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
|
@ -1073,6 +1110,77 @@ func (a userHasManyAuthMethodsTx) Count() int64 {
|
|||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userBelongsToServer struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userBelongsToServer) Where(conds ...field.Expr) *userBelongsToServer {
|
||||
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 userBelongsToServer) WithContext(ctx context.Context) *userBelongsToServer {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userBelongsToServer) Session(session *gorm.Session) *userBelongsToServer {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userBelongsToServer) Model(m *models.User) *userBelongsToServerTx {
|
||||
return &userBelongsToServerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userBelongsToServerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Append(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Replace(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Delete(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userBelongsToServerTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userBelongsToIcon struct {
|
||||
db *gorm.DB
|
||||
|
||||
|
|
Loading…
Reference in a new issue