1832 lines
47 KiB
Go
1832 lines
47 KiB
Go
// 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"
|
|
"strings"
|
|
|
|
"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 newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
|
_user := user{}
|
|
|
|
_user.userDo.UseDB(db, opts...)
|
|
_user.userDo.UseModel(&models.User{})
|
|
|
|
tableName := _user.userDo.TableName()
|
|
_user.ALL = field.NewAsterisk(tableName)
|
|
_user.ID = field.NewString(tableName, "id")
|
|
_user.Username = field.NewString(tableName, "username")
|
|
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_user.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_user.ServerId = field.NewUint(tableName, "server_id")
|
|
_user.DisplayName = field.NewString(tableName, "display_name")
|
|
_user.Description = field.NewString(tableName, "description")
|
|
_user.IsBot = field.NewBool(tableName, "is_bot")
|
|
_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")
|
|
_user.PublicKeyRsa = field.NewBytes(tableName, "public_key_rsa")
|
|
_user.PublicKeyEd = field.NewBytes(tableName, "public_key_ed")
|
|
_user.RestrictedFollow = field.NewBool(tableName, "restricted_follow")
|
|
_user.Location = field.NewField(tableName, "location")
|
|
_user.Birthday = field.NewField(tableName, "birthday")
|
|
_user.Verified = field.NewBool(tableName, "verified")
|
|
_user.PasskeyId = field.NewBytes(tableName, "passkey_id")
|
|
_user.FinishedRegistration = field.NewBool(tableName, "finished_registration")
|
|
_user.PrivateKeyRsa = field.NewBytes(tableName, "private_key_rsa")
|
|
_user.PrivateKeyEd = field.NewBytes(tableName, "private_key_ed")
|
|
_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
|
|
}
|
|
Background struct {
|
|
field.RelationField
|
|
}
|
|
Banner struct {
|
|
field.RelationField
|
|
}
|
|
RemoteInfo 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("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
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Icon", "models.MediaMetadata"),
|
|
},
|
|
Background: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Background", "models.MediaMetadata"),
|
|
},
|
|
Banner: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Banner", "models.MediaMetadata"),
|
|
},
|
|
RemoteInfo: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.RemoteInfo", "models.UserRemoteLinks"),
|
|
},
|
|
InfoFields: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.InfoFields", "models.UserInfoField"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.InfoFields.User", "models.User"),
|
|
},
|
|
},
|
|
BeingTypes: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.BeingTypes", "models.UserToBeing"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.BeingTypes.User", "models.User"),
|
|
},
|
|
},
|
|
Tags: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Tags", "models.UserToTag"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Tags.User", "models.User"),
|
|
},
|
|
},
|
|
Relations: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
TargetUser struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Relations", "models.UserToUserRelation"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Relations.User", "models.User"),
|
|
},
|
|
TargetUser: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Relations.TargetUser", "models.User"),
|
|
},
|
|
},
|
|
Pronouns: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Pronouns", "models.UserToPronoun"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Pronouns.User", "models.User"),
|
|
},
|
|
},
|
|
Roles: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
Role struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Roles", "models.UserToRole"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Roles.User", "models.User"),
|
|
},
|
|
Role: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.Roles.Role", "models.Role"),
|
|
},
|
|
},
|
|
AuthMethods: struct {
|
|
field.RelationField
|
|
User struct {
|
|
field.RelationField
|
|
}
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.AuthMethods", "models.UserAuthMethod"),
|
|
User: struct {
|
|
field.RelationField
|
|
}{
|
|
RelationField: field.NewRelation("RemoteInfo.User.AuthMethods.User", "models.User"),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
_user.InfoFields = userHasManyInfoFields{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("InfoFields", "models.UserInfoField"),
|
|
}
|
|
|
|
_user.BeingTypes = userHasManyBeingTypes{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("BeingTypes", "models.UserToBeing"),
|
|
}
|
|
|
|
_user.Tags = userHasManyTags{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Tags", "models.UserToTag"),
|
|
}
|
|
|
|
_user.Relations = userHasManyRelations{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Relations", "models.UserToUserRelation"),
|
|
}
|
|
|
|
_user.Pronouns = userHasManyPronouns{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Pronouns", "models.UserToPronoun"),
|
|
}
|
|
|
|
_user.Roles = userHasManyRoles{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Roles", "models.UserToRole"),
|
|
}
|
|
|
|
_user.AuthMethods = userHasManyAuthMethods{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
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{}),
|
|
|
|
RelationField: field.NewRelation("Icon", "models.MediaMetadata"),
|
|
}
|
|
|
|
_user.Background = userBelongsToBackground{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Background", "models.MediaMetadata"),
|
|
}
|
|
|
|
_user.Banner = userBelongsToBanner{
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
RelationField: field.NewRelation("Banner", "models.MediaMetadata"),
|
|
}
|
|
|
|
_user.fillFieldMap()
|
|
|
|
return _user
|
|
}
|
|
|
|
type user struct {
|
|
userDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.String
|
|
Username field.String
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
DeletedAt field.Field
|
|
ServerId field.Uint
|
|
DisplayName field.String
|
|
Description field.String
|
|
IsBot field.Bool
|
|
IconId field.Field
|
|
BackgroundId field.Field
|
|
BannerId field.Field
|
|
Indexable field.Bool
|
|
PublicKeyRsa field.Bytes
|
|
PublicKeyEd field.Bytes
|
|
RestrictedFollow field.Bool
|
|
Location field.Field
|
|
Birthday field.Field
|
|
Verified field.Bool
|
|
PasskeyId field.Bytes
|
|
FinishedRegistration field.Bool
|
|
PrivateKeyRsa field.Bytes
|
|
PrivateKeyEd field.Bytes
|
|
RemoteInfo userHasOneRemoteInfo
|
|
|
|
InfoFields userHasManyInfoFields
|
|
|
|
BeingTypes userHasManyBeingTypes
|
|
|
|
Tags userHasManyTags
|
|
|
|
Relations userHasManyRelations
|
|
|
|
Pronouns userHasManyPronouns
|
|
|
|
Roles userHasManyRoles
|
|
|
|
AuthMethods userHasManyAuthMethods
|
|
|
|
Server userBelongsToServer
|
|
|
|
Icon userBelongsToIcon
|
|
|
|
Background userBelongsToBackground
|
|
|
|
Banner userBelongsToBanner
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (u user) Table(newTableName string) *user {
|
|
u.userDo.UseTable(newTableName)
|
|
return u.updateTableName(newTableName)
|
|
}
|
|
|
|
func (u user) As(alias string) *user {
|
|
u.userDo.DO = *(u.userDo.As(alias).(*gen.DO))
|
|
return u.updateTableName(alias)
|
|
}
|
|
|
|
func (u *user) updateTableName(table string) *user {
|
|
u.ALL = field.NewAsterisk(table)
|
|
u.ID = field.NewString(table, "id")
|
|
u.Username = field.NewString(table, "username")
|
|
u.CreatedAt = field.NewTime(table, "created_at")
|
|
u.UpdatedAt = field.NewTime(table, "updated_at")
|
|
u.DeletedAt = field.NewField(table, "deleted_at")
|
|
u.ServerId = field.NewUint(table, "server_id")
|
|
u.DisplayName = field.NewString(table, "display_name")
|
|
u.Description = field.NewString(table, "description")
|
|
u.IsBot = field.NewBool(table, "is_bot")
|
|
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")
|
|
u.PublicKeyRsa = field.NewBytes(table, "public_key_rsa")
|
|
u.PublicKeyEd = field.NewBytes(table, "public_key_ed")
|
|
u.RestrictedFollow = field.NewBool(table, "restricted_follow")
|
|
u.Location = field.NewField(table, "location")
|
|
u.Birthday = field.NewField(table, "birthday")
|
|
u.Verified = field.NewBool(table, "verified")
|
|
u.PasskeyId = field.NewBytes(table, "passkey_id")
|
|
u.FinishedRegistration = field.NewBool(table, "finished_registration")
|
|
u.PrivateKeyRsa = field.NewBytes(table, "private_key_rsa")
|
|
u.PrivateKeyEd = field.NewBytes(table, "private_key_ed")
|
|
|
|
u.fillFieldMap()
|
|
|
|
return u
|
|
}
|
|
|
|
func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := u.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (u *user) fillFieldMap() {
|
|
u.fieldMap = make(map[string]field.Expr, 35)
|
|
u.fieldMap["id"] = u.ID
|
|
u.fieldMap["username"] = u.Username
|
|
u.fieldMap["created_at"] = u.CreatedAt
|
|
u.fieldMap["updated_at"] = u.UpdatedAt
|
|
u.fieldMap["deleted_at"] = u.DeletedAt
|
|
u.fieldMap["server_id"] = u.ServerId
|
|
u.fieldMap["display_name"] = u.DisplayName
|
|
u.fieldMap["description"] = u.Description
|
|
u.fieldMap["is_bot"] = u.IsBot
|
|
u.fieldMap["icon_id"] = u.IconId
|
|
u.fieldMap["background_id"] = u.BackgroundId
|
|
u.fieldMap["banner_id"] = u.BannerId
|
|
u.fieldMap["indexable"] = u.Indexable
|
|
u.fieldMap["public_key_rsa"] = u.PublicKeyRsa
|
|
u.fieldMap["public_key_ed"] = u.PublicKeyEd
|
|
u.fieldMap["restricted_follow"] = u.RestrictedFollow
|
|
u.fieldMap["location"] = u.Location
|
|
u.fieldMap["birthday"] = u.Birthday
|
|
u.fieldMap["verified"] = u.Verified
|
|
u.fieldMap["passkey_id"] = u.PasskeyId
|
|
u.fieldMap["finished_registration"] = u.FinishedRegistration
|
|
u.fieldMap["private_key_rsa"] = u.PrivateKeyRsa
|
|
u.fieldMap["private_key_ed"] = u.PrivateKeyEd
|
|
|
|
}
|
|
|
|
func (u user) clone(db *gorm.DB) user {
|
|
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return u
|
|
}
|
|
|
|
func (u user) replaceDB(db *gorm.DB) user {
|
|
u.userDo.ReplaceDB(db)
|
|
return u
|
|
}
|
|
|
|
type userHasOneRemoteInfo struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
|
|
User struct {
|
|
field.RelationField
|
|
Server struct {
|
|
field.RelationField
|
|
Icon struct {
|
|
field.RelationField
|
|
}
|
|
}
|
|
Icon struct {
|
|
field.RelationField
|
|
}
|
|
Background struct {
|
|
field.RelationField
|
|
}
|
|
Banner struct {
|
|
field.RelationField
|
|
}
|
|
RemoteInfo 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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func (a userHasOneRemoteInfo) Where(conds ...field.Expr) *userHasOneRemoteInfo {
|
|
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 userHasOneRemoteInfo) WithContext(ctx context.Context) *userHasOneRemoteInfo {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasOneRemoteInfo) Session(session *gorm.Session) *userHasOneRemoteInfo {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasOneRemoteInfo) Model(m *models.User) *userHasOneRemoteInfoTx {
|
|
return &userHasOneRemoteInfoTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasOneRemoteInfoTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasOneRemoteInfoTx) Find() (result *models.UserRemoteLinks, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasOneRemoteInfoTx) Append(values ...*models.UserRemoteLinks) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasOneRemoteInfoTx) Replace(values ...*models.UserRemoteLinks) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasOneRemoteInfoTx) Delete(values ...*models.UserRemoteLinks) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasOneRemoteInfoTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasOneRemoteInfoTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyInfoFields struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyInfoFields) Where(conds ...field.Expr) *userHasManyInfoFields {
|
|
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 userHasManyInfoFields) WithContext(ctx context.Context) *userHasManyInfoFields {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyInfoFields) Session(session *gorm.Session) *userHasManyInfoFields {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyInfoFields) Model(m *models.User) *userHasManyInfoFieldsTx {
|
|
return &userHasManyInfoFieldsTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyInfoFieldsTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyInfoFieldsTx) Find() (result []*models.UserInfoField, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyInfoFieldsTx) Append(values ...*models.UserInfoField) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyInfoFieldsTx) Replace(values ...*models.UserInfoField) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyInfoFieldsTx) Delete(values ...*models.UserInfoField) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyInfoFieldsTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyInfoFieldsTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyBeingTypes struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyBeingTypes) Where(conds ...field.Expr) *userHasManyBeingTypes {
|
|
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 userHasManyBeingTypes) WithContext(ctx context.Context) *userHasManyBeingTypes {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyBeingTypes) Session(session *gorm.Session) *userHasManyBeingTypes {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyBeingTypes) Model(m *models.User) *userHasManyBeingTypesTx {
|
|
return &userHasManyBeingTypesTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyBeingTypesTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyBeingTypesTx) Find() (result []*models.UserToBeing, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyBeingTypesTx) Append(values ...*models.UserToBeing) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyBeingTypesTx) Replace(values ...*models.UserToBeing) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyBeingTypesTx) Delete(values ...*models.UserToBeing) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyBeingTypesTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyBeingTypesTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyTags struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyTags) Where(conds ...field.Expr) *userHasManyTags {
|
|
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 userHasManyTags) WithContext(ctx context.Context) *userHasManyTags {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyTags) Session(session *gorm.Session) *userHasManyTags {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyTags) Model(m *models.User) *userHasManyTagsTx {
|
|
return &userHasManyTagsTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyTagsTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyTagsTx) Find() (result []*models.UserToTag, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyTagsTx) Append(values ...*models.UserToTag) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyTagsTx) Replace(values ...*models.UserToTag) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyTagsTx) Delete(values ...*models.UserToTag) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyTagsTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyTagsTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyRelations struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyRelations) Where(conds ...field.Expr) *userHasManyRelations {
|
|
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 userHasManyRelations) WithContext(ctx context.Context) *userHasManyRelations {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyRelations) Session(session *gorm.Session) *userHasManyRelations {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyRelations) Model(m *models.User) *userHasManyRelationsTx {
|
|
return &userHasManyRelationsTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyRelationsTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyRelationsTx) Find() (result []*models.UserToUserRelation, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyRelationsTx) Append(values ...*models.UserToUserRelation) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRelationsTx) Replace(values ...*models.UserToUserRelation) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRelationsTx) Delete(values ...*models.UserToUserRelation) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRelationsTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyRelationsTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyPronouns struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyPronouns) Where(conds ...field.Expr) *userHasManyPronouns {
|
|
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 userHasManyPronouns) WithContext(ctx context.Context) *userHasManyPronouns {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyPronouns) Session(session *gorm.Session) *userHasManyPronouns {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyPronouns) Model(m *models.User) *userHasManyPronounsTx {
|
|
return &userHasManyPronounsTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyPronounsTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyPronounsTx) Find() (result []*models.UserToPronoun, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyPronounsTx) Append(values ...*models.UserToPronoun) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyPronounsTx) Replace(values ...*models.UserToPronoun) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyPronounsTx) Delete(values ...*models.UserToPronoun) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyPronounsTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyPronounsTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyRoles struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyRoles) Where(conds ...field.Expr) *userHasManyRoles {
|
|
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 userHasManyRoles) WithContext(ctx context.Context) *userHasManyRoles {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyRoles) Session(session *gorm.Session) *userHasManyRoles {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyRoles) Model(m *models.User) *userHasManyRolesTx {
|
|
return &userHasManyRolesTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyRolesTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyRolesTx) Find() (result []*models.UserToRole, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyRolesTx) Append(values ...*models.UserToRole) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRolesTx) Replace(values ...*models.UserToRole) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRolesTx) Delete(values ...*models.UserToRole) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyRolesTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userHasManyRolesTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userHasManyAuthMethods struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userHasManyAuthMethods) Where(conds ...field.Expr) *userHasManyAuthMethods {
|
|
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 userHasManyAuthMethods) WithContext(ctx context.Context) *userHasManyAuthMethods {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyAuthMethods) Session(session *gorm.Session) *userHasManyAuthMethods {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userHasManyAuthMethods) Model(m *models.User) *userHasManyAuthMethodsTx {
|
|
return &userHasManyAuthMethodsTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userHasManyAuthMethodsTx struct{ tx *gorm.Association }
|
|
|
|
func (a userHasManyAuthMethodsTx) Find() (result []*models.UserAuthMethod, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userHasManyAuthMethodsTx) Append(values ...*models.UserAuthMethod) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyAuthMethodsTx) Replace(values ...*models.UserAuthMethod) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyAuthMethodsTx) Delete(values ...*models.UserAuthMethod) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userHasManyAuthMethodsTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
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
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userBelongsToIcon) Where(conds ...field.Expr) *userBelongsToIcon {
|
|
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 userBelongsToIcon) WithContext(ctx context.Context) *userBelongsToIcon {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToIcon) Session(session *gorm.Session) *userBelongsToIcon {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToIcon) Model(m *models.User) *userBelongsToIconTx {
|
|
return &userBelongsToIconTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userBelongsToIconTx struct{ tx *gorm.Association }
|
|
|
|
func (a userBelongsToIconTx) Find() (result *models.MediaMetadata, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userBelongsToIconTx) Append(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToIconTx) Replace(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToIconTx) Delete(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToIconTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userBelongsToIconTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userBelongsToBackground struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userBelongsToBackground) Where(conds ...field.Expr) *userBelongsToBackground {
|
|
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 userBelongsToBackground) WithContext(ctx context.Context) *userBelongsToBackground {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToBackground) Session(session *gorm.Session) *userBelongsToBackground {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToBackground) Model(m *models.User) *userBelongsToBackgroundTx {
|
|
return &userBelongsToBackgroundTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userBelongsToBackgroundTx struct{ tx *gorm.Association }
|
|
|
|
func (a userBelongsToBackgroundTx) Find() (result *models.MediaMetadata, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userBelongsToBackgroundTx) Append(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBackgroundTx) Replace(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBackgroundTx) Delete(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBackgroundTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userBelongsToBackgroundTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userBelongsToBanner struct {
|
|
db *gorm.DB
|
|
|
|
field.RelationField
|
|
}
|
|
|
|
func (a userBelongsToBanner) Where(conds ...field.Expr) *userBelongsToBanner {
|
|
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 userBelongsToBanner) WithContext(ctx context.Context) *userBelongsToBanner {
|
|
a.db = a.db.WithContext(ctx)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToBanner) Session(session *gorm.Session) *userBelongsToBanner {
|
|
a.db = a.db.Session(session)
|
|
return &a
|
|
}
|
|
|
|
func (a userBelongsToBanner) Model(m *models.User) *userBelongsToBannerTx {
|
|
return &userBelongsToBannerTx{a.db.Model(m).Association(a.Name())}
|
|
}
|
|
|
|
type userBelongsToBannerTx struct{ tx *gorm.Association }
|
|
|
|
func (a userBelongsToBannerTx) Find() (result *models.MediaMetadata, err error) {
|
|
return result, a.tx.Find(&result)
|
|
}
|
|
|
|
func (a userBelongsToBannerTx) Append(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Append(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBannerTx) Replace(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Replace(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBannerTx) Delete(values ...*models.MediaMetadata) (err error) {
|
|
targetValues := make([]interface{}, len(values))
|
|
for i, v := range values {
|
|
targetValues[i] = v
|
|
}
|
|
return a.tx.Delete(targetValues...)
|
|
}
|
|
|
|
func (a userBelongsToBannerTx) Clear() error {
|
|
return a.tx.Clear()
|
|
}
|
|
|
|
func (a userBelongsToBannerTx) Count() int64 {
|
|
return a.tx.Count()
|
|
}
|
|
|
|
type userDo struct{ gen.DO }
|
|
|
|
type IUserDo interface {
|
|
gen.SubQuery
|
|
Debug() IUserDo
|
|
WithContext(ctx context.Context) IUserDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IUserDo
|
|
WriteDB() IUserDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IUserDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IUserDo
|
|
Not(conds ...gen.Condition) IUserDo
|
|
Or(conds ...gen.Condition) IUserDo
|
|
Select(conds ...field.Expr) IUserDo
|
|
Where(conds ...gen.Condition) IUserDo
|
|
Order(conds ...field.Expr) IUserDo
|
|
Distinct(cols ...field.Expr) IUserDo
|
|
Omit(cols ...field.Expr) IUserDo
|
|
Join(table schema.Tabler, on ...field.Expr) IUserDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IUserDo
|
|
Group(cols ...field.Expr) IUserDo
|
|
Having(conds ...gen.Condition) IUserDo
|
|
Limit(limit int) IUserDo
|
|
Offset(offset int) IUserDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo
|
|
Unscoped() IUserDo
|
|
Create(values ...*models.User) error
|
|
CreateInBatches(values []*models.User, batchSize int) error
|
|
Save(values ...*models.User) error
|
|
First() (*models.User, error)
|
|
Take() (*models.User, error)
|
|
Last() (*models.User, error)
|
|
Find() ([]*models.User, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.User, err error)
|
|
FindInBatches(result *[]*models.User, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*models.User) (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) IUserDo
|
|
Assign(attrs ...field.AssignExpr) IUserDo
|
|
Joins(fields ...field.RelationField) IUserDo
|
|
Preload(fields ...field.RelationField) IUserDo
|
|
FirstOrInit() (*models.User, error)
|
|
FirstOrCreate() (*models.User, error)
|
|
FindByPage(offset int, limit int) (result []*models.User, count int64, err error)
|
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
|
Scan(result interface{}) (err error)
|
|
Returning(value interface{}, columns ...string) IUserDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
|
|
GetByUsernameUnrestricted(username string) (result *models.User, err error)
|
|
GetByUsername(username string) (result *models.User, err error)
|
|
GetPagedTruePublic(pageNr uint) (result []models.User, err error)
|
|
GetPagedAllDeleted(pageNr uint) (result []models.User, err error)
|
|
GetPagedAllNonDeleted(pageNr uint) (result []models.User, err error)
|
|
GdprUsers() (err error)
|
|
}
|
|
|
|
// Get a user by a username, ignoring all restrictions on that user
|
|
//
|
|
// SELECT * FROM @@table WHERE username = @username AND deleted_at IS NULL LIMIT 1
|
|
func (u userDo) GetByUsernameUnrestricted(username string) (result *models.User, err error) {
|
|
var params []interface{}
|
|
|
|
var generateSQL strings.Builder
|
|
params = append(params, username)
|
|
generateSQL.WriteString("SELECT * FROM users WHERE username = ? AND deleted_at IS NULL LIMIT 1 ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
// Get a user by the username.
|
|
// Restricted to users visible to ActivityPub
|
|
//
|
|
// SELECT * FROM @@table WHERE
|
|
//
|
|
// username = @username AND
|
|
// deleted_at IS NULL AND
|
|
// finished_registration = true AND
|
|
// verified = true
|
|
//
|
|
// LIMIT 1
|
|
func (u userDo) GetByUsername(username string) (result *models.User, err error) {
|
|
var params []interface{}
|
|
|
|
var generateSQL strings.Builder
|
|
params = append(params, username)
|
|
generateSQL.WriteString("SELECT * FROM users WHERE username = ? AND deleted_at IS NULL AND finished_registration = true AND verified = true LIMIT 1 ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
// Get all true public accounts (verified & no restricted follow & indexable)
|
|
// in a paged manner, sorted by date saved
|
|
//
|
|
// SELECT * FROM @@table WHERE
|
|
//
|
|
// deleted_at IS NULL AND
|
|
// verified = true AND
|
|
// restricted_follow = false AND
|
|
// indexable = true
|
|
//
|
|
// ORDER BY created_at ASC
|
|
// LIMIT 50
|
|
// OFFSET @pageNr * 50
|
|
func (u userDo) GetPagedTruePublic(pageNr uint) (result []models.User, err error) {
|
|
var params []interface{}
|
|
|
|
var generateSQL strings.Builder
|
|
params = append(params, pageNr)
|
|
generateSQL.WriteString("SELECT * FROM users WHERE deleted_at IS NULL AND verified = true AND restricted_follow = false AND indexable = true ORDER BY created_at ASC LIMIT 50 OFFSET ? * 50 ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Find(&result) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
// Get all deleted accounts in a paged manner, sorted by date saved
|
|
//
|
|
// SELECT * FROM @@table WHERE
|
|
//
|
|
// deleted_at IS NOT NULL AND
|
|
//
|
|
// ORDER BY created_at ASC
|
|
// LIMIT 50
|
|
// OFFSET @pageNr * 50
|
|
func (u userDo) GetPagedAllDeleted(pageNr uint) (result []models.User, err error) {
|
|
var params []interface{}
|
|
|
|
var generateSQL strings.Builder
|
|
params = append(params, pageNr)
|
|
generateSQL.WriteString("SELECT * FROM users WHERE deleted_at IS NOT NULL AND ORDER BY created_at ASC LIMIT 50 OFFSET ? * 50 ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Find(&result) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
// Get all accounts that aren't deleted in a paged manner, sorted by date saved
|
|
//
|
|
// SELECT * FROM @@table WHERE
|
|
//
|
|
// deleted_at IS NULL
|
|
//
|
|
// ORDER BY created_at ASC
|
|
// LIMIT 50
|
|
// OFFSET @pageNr * 50
|
|
func (u userDo) GetPagedAllNonDeleted(pageNr uint) (result []models.User, err error) {
|
|
var params []interface{}
|
|
|
|
var generateSQL strings.Builder
|
|
params = append(params, pageNr)
|
|
generateSQL.WriteString("SELECT * FROM users WHERE deleted_at IS NULL ORDER BY created_at ASC LIMIT 50 OFFSET ? * 50 ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Find(&result) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
// Gdpr deleted users
|
|
//
|
|
// DELETE FROM @@table WHERE deleted_at IS NOT NULL AND deleted_at + interval '30 days' < NOW()
|
|
func (u userDo) GdprUsers() (err error) {
|
|
var generateSQL strings.Builder
|
|
generateSQL.WriteString("DELETE FROM users WHERE deleted_at IS NOT NULL AND deleted_at + interval '30 days' < NOW() ")
|
|
|
|
var executeSQL *gorm.DB
|
|
executeSQL = u.UnderlyingDB().Exec(generateSQL.String()) // ignore_security_alert
|
|
err = executeSQL.Error
|
|
|
|
return
|
|
}
|
|
|
|
func (u userDo) Debug() IUserDo {
|
|
return u.withDO(u.DO.Debug())
|
|
}
|
|
|
|
func (u userDo) WithContext(ctx context.Context) IUserDo {
|
|
return u.withDO(u.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (u userDo) ReadDB() IUserDo {
|
|
return u.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (u userDo) WriteDB() IUserDo {
|
|
return u.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (u userDo) Session(config *gorm.Session) IUserDo {
|
|
return u.withDO(u.DO.Session(config))
|
|
}
|
|
|
|
func (u userDo) Clauses(conds ...clause.Expression) IUserDo {
|
|
return u.withDO(u.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (u userDo) Returning(value interface{}, columns ...string) IUserDo {
|
|
return u.withDO(u.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (u userDo) Not(conds ...gen.Condition) IUserDo {
|
|
return u.withDO(u.DO.Not(conds...))
|
|
}
|
|
|
|
func (u userDo) Or(conds ...gen.Condition) IUserDo {
|
|
return u.withDO(u.DO.Or(conds...))
|
|
}
|
|
|
|
func (u userDo) Select(conds ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Select(conds...))
|
|
}
|
|
|
|
func (u userDo) Where(conds ...gen.Condition) IUserDo {
|
|
return u.withDO(u.DO.Where(conds...))
|
|
}
|
|
|
|
func (u userDo) Order(conds ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Order(conds...))
|
|
}
|
|
|
|
func (u userDo) Distinct(cols ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (u userDo) Omit(cols ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Omit(cols...))
|
|
}
|
|
|
|
func (u userDo) Join(table schema.Tabler, on ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Join(table, on...))
|
|
}
|
|
|
|
func (u userDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (u userDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (u userDo) Group(cols ...field.Expr) IUserDo {
|
|
return u.withDO(u.DO.Group(cols...))
|
|
}
|
|
|
|
func (u userDo) Having(conds ...gen.Condition) IUserDo {
|
|
return u.withDO(u.DO.Having(conds...))
|
|
}
|
|
|
|
func (u userDo) Limit(limit int) IUserDo {
|
|
return u.withDO(u.DO.Limit(limit))
|
|
}
|
|
|
|
func (u userDo) Offset(offset int) IUserDo {
|
|
return u.withDO(u.DO.Offset(offset))
|
|
}
|
|
|
|
func (u userDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo {
|
|
return u.withDO(u.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (u userDo) Unscoped() IUserDo {
|
|
return u.withDO(u.DO.Unscoped())
|
|
}
|
|
|
|
func (u userDo) Create(values ...*models.User) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Create(values)
|
|
}
|
|
|
|
func (u userDo) CreateInBatches(values []*models.User, batchSize int) error {
|
|
return u.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 (u userDo) Save(values ...*models.User) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Save(values)
|
|
}
|
|
|
|
func (u userDo) First() (*models.User, error) {
|
|
if result, err := u.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.User), nil
|
|
}
|
|
}
|
|
|
|
func (u userDo) Take() (*models.User, error) {
|
|
if result, err := u.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.User), nil
|
|
}
|
|
}
|
|
|
|
func (u userDo) Last() (*models.User, error) {
|
|
if result, err := u.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.User), nil
|
|
}
|
|
}
|
|
|
|
func (u userDo) Find() ([]*models.User, error) {
|
|
result, err := u.DO.Find()
|
|
return result.([]*models.User), err
|
|
}
|
|
|
|
func (u userDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.User, err error) {
|
|
buf := make([]*models.User, 0, batchSize)
|
|
err = u.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 (u userDo) FindInBatches(result *[]*models.User, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return u.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (u userDo) Attrs(attrs ...field.AssignExpr) IUserDo {
|
|
return u.withDO(u.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (u userDo) Assign(attrs ...field.AssignExpr) IUserDo {
|
|
return u.withDO(u.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (u userDo) Joins(fields ...field.RelationField) IUserDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Joins(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userDo) Preload(fields ...field.RelationField) IUserDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Preload(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userDo) FirstOrInit() (*models.User, error) {
|
|
if result, err := u.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.User), nil
|
|
}
|
|
}
|
|
|
|
func (u userDo) FirstOrCreate() (*models.User, error) {
|
|
if result, err := u.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*models.User), nil
|
|
}
|
|
}
|
|
|
|
func (u userDo) FindByPage(offset int, limit int) (result []*models.User, count int64, err error) {
|
|
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (u userDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = u.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = u.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (u userDo) Scan(result interface{}) (err error) {
|
|
return u.DO.Scan(result)
|
|
}
|
|
|
|
func (u userDo) Delete(models ...*models.User) (result gen.ResultInfo, err error) {
|
|
return u.DO.Delete(models)
|
|
}
|
|
|
|
func (u *userDo) withDO(do gen.Dao) *userDo {
|
|
u.DO = *do.(*gen.DO)
|
|
return u
|
|
}
|