This commit is contained in:
parent
11e0059631
commit
b33f6c2af7
8 changed files with 3609 additions and 7 deletions
684
storage-new/dbgen/feeds.gen.go
Normal file
684
storage-new/dbgen/feeds.gen.go
Normal file
|
@ -0,0 +1,684 @@
|
|||
// 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"
|
||||
|
||||
"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 newFeed(db *gorm.DB, opts ...gen.DOOption) feed {
|
||||
_feed := feed{}
|
||||
|
||||
_feed.feedDo.UseDB(db, opts...)
|
||||
_feed.feedDo.UseModel(&models.Feed{})
|
||||
|
||||
tableName := _feed.feedDo.TableName()
|
||||
_feed.ALL = field.NewAsterisk(tableName)
|
||||
_feed.ID = field.NewUint(tableName, "id")
|
||||
_feed.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_feed.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_feed.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_feed.Name = field.NewString(tableName, "name")
|
||||
_feed.OwnerId = field.NewString(tableName, "owner_id")
|
||||
_feed.IsDefault = field.NewBool(tableName, "is_default")
|
||||
_feed.PublicKey = field.NewField(tableName, "public_key")
|
||||
_feed.Owner = feedBelongsToOwner{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Owner", "models.User"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
Background: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Background", "models.MediaMetadata"),
|
||||
},
|
||||
Banner: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Banner", "models.MediaMetadata"),
|
||||
},
|
||||
RemoteInfo: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.RemoteInfo", "models.UserRemoteLinks"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.RemoteInfo.User", "models.User"),
|
||||
},
|
||||
},
|
||||
InfoFields: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.InfoFields", "models.UserInfoField"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.InfoFields.User", "models.User"),
|
||||
},
|
||||
},
|
||||
BeingTypes: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.BeingTypes", "models.UserToBeing"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.BeingTypes.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Tags", "models.UserToTag"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Tags.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Relations: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Relations", "models.UserToUserRelation"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Relations.User", "models.User"),
|
||||
},
|
||||
TargetUser: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Relations.TargetUser", "models.User"),
|
||||
},
|
||||
},
|
||||
Pronouns: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Pronouns", "models.UserToPronoun"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Pronouns.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Roles: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Roles", "models.UserToRole"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Roles.User", "models.User"),
|
||||
},
|
||||
Role: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.Roles.Role", "models.Role"),
|
||||
},
|
||||
},
|
||||
AuthMethods: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.AuthMethods", "models.UserAuthMethod"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Owner.AuthMethods.User", "models.User"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_feed.fillFieldMap()
|
||||
|
||||
return _feed
|
||||
}
|
||||
|
||||
type feed struct {
|
||||
feedDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
OwnerId field.String
|
||||
IsDefault field.Bool
|
||||
PublicKey field.Field
|
||||
Owner feedBelongsToOwner
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (f feed) Table(newTableName string) *feed {
|
||||
f.feedDo.UseTable(newTableName)
|
||||
return f.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (f feed) As(alias string) *feed {
|
||||
f.feedDo.DO = *(f.feedDo.As(alias).(*gen.DO))
|
||||
return f.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (f *feed) updateTableName(table string) *feed {
|
||||
f.ALL = field.NewAsterisk(table)
|
||||
f.ID = field.NewUint(table, "id")
|
||||
f.CreatedAt = field.NewTime(table, "created_at")
|
||||
f.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
f.DeletedAt = field.NewField(table, "deleted_at")
|
||||
f.Name = field.NewString(table, "name")
|
||||
f.OwnerId = field.NewString(table, "owner_id")
|
||||
f.IsDefault = field.NewBool(table, "is_default")
|
||||
f.PublicKey = field.NewField(table, "public_key")
|
||||
|
||||
f.fillFieldMap()
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *feed) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := f.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (f *feed) fillFieldMap() {
|
||||
f.fieldMap = make(map[string]field.Expr, 9)
|
||||
f.fieldMap["id"] = f.ID
|
||||
f.fieldMap["created_at"] = f.CreatedAt
|
||||
f.fieldMap["updated_at"] = f.UpdatedAt
|
||||
f.fieldMap["deleted_at"] = f.DeletedAt
|
||||
f.fieldMap["name"] = f.Name
|
||||
f.fieldMap["owner_id"] = f.OwnerId
|
||||
f.fieldMap["is_default"] = f.IsDefault
|
||||
f.fieldMap["public_key"] = f.PublicKey
|
||||
|
||||
}
|
||||
|
||||
func (f feed) clone(db *gorm.DB) feed {
|
||||
f.feedDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return f
|
||||
}
|
||||
|
||||
func (f feed) replaceDB(db *gorm.DB) feed {
|
||||
f.feedDo.ReplaceDB(db)
|
||||
return f
|
||||
}
|
||||
|
||||
type feedBelongsToOwner struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
Background struct {
|
||||
field.RelationField
|
||||
}
|
||||
Banner struct {
|
||||
field.RelationField
|
||||
}
|
||||
RemoteInfo struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
InfoFields struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
BeingTypes struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Relations struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Pronouns struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Roles struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
AuthMethods struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwner) Where(conds ...field.Expr) *feedBelongsToOwner {
|
||||
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 feedBelongsToOwner) WithContext(ctx context.Context) *feedBelongsToOwner {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwner) Session(session *gorm.Session) *feedBelongsToOwner {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwner) Model(m *models.Feed) *feedBelongsToOwnerTx {
|
||||
return &feedBelongsToOwnerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type feedBelongsToOwnerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a feedBelongsToOwnerTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwnerTx) Append(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwnerTx) Replace(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwnerTx) Delete(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwnerTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a feedBelongsToOwnerTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type feedDo struct{ gen.DO }
|
||||
|
||||
type IFeedDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IFeedDo
|
||||
WithContext(ctx context.Context) IFeedDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IFeedDo
|
||||
WriteDB() IFeedDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IFeedDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IFeedDo
|
||||
Not(conds ...gen.Condition) IFeedDo
|
||||
Or(conds ...gen.Condition) IFeedDo
|
||||
Select(conds ...field.Expr) IFeedDo
|
||||
Where(conds ...gen.Condition) IFeedDo
|
||||
Order(conds ...field.Expr) IFeedDo
|
||||
Distinct(cols ...field.Expr) IFeedDo
|
||||
Omit(cols ...field.Expr) IFeedDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IFeedDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IFeedDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IFeedDo
|
||||
Group(cols ...field.Expr) IFeedDo
|
||||
Having(conds ...gen.Condition) IFeedDo
|
||||
Limit(limit int) IFeedDo
|
||||
Offset(offset int) IFeedDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IFeedDo
|
||||
Unscoped() IFeedDo
|
||||
Create(values ...*models.Feed) error
|
||||
CreateInBatches(values []*models.Feed, batchSize int) error
|
||||
Save(values ...*models.Feed) error
|
||||
First() (*models.Feed, error)
|
||||
Take() (*models.Feed, error)
|
||||
Last() (*models.Feed, error)
|
||||
Find() ([]*models.Feed, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Feed, err error)
|
||||
FindInBatches(result *[]*models.Feed, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.Feed) (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) IFeedDo
|
||||
Assign(attrs ...field.AssignExpr) IFeedDo
|
||||
Joins(fields ...field.RelationField) IFeedDo
|
||||
Preload(fields ...field.RelationField) IFeedDo
|
||||
FirstOrInit() (*models.Feed, error)
|
||||
FirstOrCreate() (*models.Feed, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Feed, 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) IFeedDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (f feedDo) Debug() IFeedDo {
|
||||
return f.withDO(f.DO.Debug())
|
||||
}
|
||||
|
||||
func (f feedDo) WithContext(ctx context.Context) IFeedDo {
|
||||
return f.withDO(f.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (f feedDo) ReadDB() IFeedDo {
|
||||
return f.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (f feedDo) WriteDB() IFeedDo {
|
||||
return f.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (f feedDo) Session(config *gorm.Session) IFeedDo {
|
||||
return f.withDO(f.DO.Session(config))
|
||||
}
|
||||
|
||||
func (f feedDo) Clauses(conds ...clause.Expression) IFeedDo {
|
||||
return f.withDO(f.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Returning(value interface{}, columns ...string) IFeedDo {
|
||||
return f.withDO(f.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (f feedDo) Not(conds ...gen.Condition) IFeedDo {
|
||||
return f.withDO(f.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Or(conds ...gen.Condition) IFeedDo {
|
||||
return f.withDO(f.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Select(conds ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Where(conds ...gen.Condition) IFeedDo {
|
||||
return f.withDO(f.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Order(conds ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Distinct(cols ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (f feedDo) Omit(cols ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (f feedDo) Join(table schema.Tabler, on ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (f feedDo) LeftJoin(table schema.Tabler, on ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (f feedDo) RightJoin(table schema.Tabler, on ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (f feedDo) Group(cols ...field.Expr) IFeedDo {
|
||||
return f.withDO(f.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (f feedDo) Having(conds ...gen.Condition) IFeedDo {
|
||||
return f.withDO(f.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (f feedDo) Limit(limit int) IFeedDo {
|
||||
return f.withDO(f.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (f feedDo) Offset(offset int) IFeedDo {
|
||||
return f.withDO(f.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (f feedDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IFeedDo {
|
||||
return f.withDO(f.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (f feedDo) Unscoped() IFeedDo {
|
||||
return f.withDO(f.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (f feedDo) Create(values ...*models.Feed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return f.DO.Create(values)
|
||||
}
|
||||
|
||||
func (f feedDo) CreateInBatches(values []*models.Feed, batchSize int) error {
|
||||
return f.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 (f feedDo) Save(values ...*models.Feed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return f.DO.Save(values)
|
||||
}
|
||||
|
||||
func (f feedDo) First() (*models.Feed, error) {
|
||||
if result, err := f.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Feed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f feedDo) Take() (*models.Feed, error) {
|
||||
if result, err := f.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Feed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f feedDo) Last() (*models.Feed, error) {
|
||||
if result, err := f.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Feed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f feedDo) Find() ([]*models.Feed, error) {
|
||||
result, err := f.DO.Find()
|
||||
return result.([]*models.Feed), err
|
||||
}
|
||||
|
||||
func (f feedDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Feed, err error) {
|
||||
buf := make([]*models.Feed, 0, batchSize)
|
||||
err = f.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 (f feedDo) FindInBatches(result *[]*models.Feed, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return f.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (f feedDo) Attrs(attrs ...field.AssignExpr) IFeedDo {
|
||||
return f.withDO(f.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (f feedDo) Assign(attrs ...field.AssignExpr) IFeedDo {
|
||||
return f.withDO(f.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (f feedDo) Joins(fields ...field.RelationField) IFeedDo {
|
||||
for _, _f := range fields {
|
||||
f = *f.withDO(f.DO.Joins(_f))
|
||||
}
|
||||
return &f
|
||||
}
|
||||
|
||||
func (f feedDo) Preload(fields ...field.RelationField) IFeedDo {
|
||||
for _, _f := range fields {
|
||||
f = *f.withDO(f.DO.Preload(_f))
|
||||
}
|
||||
return &f
|
||||
}
|
||||
|
||||
func (f feedDo) FirstOrInit() (*models.Feed, error) {
|
||||
if result, err := f.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Feed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f feedDo) FirstOrCreate() (*models.Feed, error) {
|
||||
if result, err := f.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Feed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (f feedDo) FindByPage(offset int, limit int) (result []*models.Feed, count int64, err error) {
|
||||
result, err = f.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 = f.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (f feedDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = f.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = f.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (f feedDo) Scan(result interface{}) (err error) {
|
||||
return f.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (f feedDo) Delete(models ...*models.Feed) (result gen.ResultInfo, err error) {
|
||||
return f.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (f *feedDo) withDO(do gen.Dao) *feedDo {
|
||||
f.DO = *do.(*gen.DO)
|
||||
return f
|
||||
}
|
|
@ -19,13 +19,17 @@ var (
|
|||
Q = new(Query)
|
||||
AccessToken *accessToken
|
||||
Emote *emote
|
||||
Feed *feed
|
||||
LoginProcessToken *loginProcessToken
|
||||
MediaMetadata *mediaMetadata
|
||||
Note *note
|
||||
NoteTag *noteTag
|
||||
NoteToAttachment *noteToAttachment
|
||||
NoteToBoost *noteToBoost
|
||||
NoteToEmote *noteToEmote
|
||||
NoteToFeed *noteToFeed
|
||||
NoteToPing *noteToPing
|
||||
Notification *notification
|
||||
Reaction *reaction
|
||||
RemoteServer *remoteServer
|
||||
Role *role
|
||||
|
@ -44,13 +48,17 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
|||
*Q = *Use(db, opts...)
|
||||
AccessToken = &Q.AccessToken
|
||||
Emote = &Q.Emote
|
||||
Feed = &Q.Feed
|
||||
LoginProcessToken = &Q.LoginProcessToken
|
||||
MediaMetadata = &Q.MediaMetadata
|
||||
Note = &Q.Note
|
||||
NoteTag = &Q.NoteTag
|
||||
NoteToAttachment = &Q.NoteToAttachment
|
||||
NoteToBoost = &Q.NoteToBoost
|
||||
NoteToEmote = &Q.NoteToEmote
|
||||
NoteToFeed = &Q.NoteToFeed
|
||||
NoteToPing = &Q.NoteToPing
|
||||
Notification = &Q.Notification
|
||||
Reaction = &Q.Reaction
|
||||
RemoteServer = &Q.RemoteServer
|
||||
Role = &Q.Role
|
||||
|
@ -70,13 +78,17 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
|||
db: db,
|
||||
AccessToken: newAccessToken(db, opts...),
|
||||
Emote: newEmote(db, opts...),
|
||||
Feed: newFeed(db, opts...),
|
||||
LoginProcessToken: newLoginProcessToken(db, opts...),
|
||||
MediaMetadata: newMediaMetadata(db, opts...),
|
||||
Note: newNote(db, opts...),
|
||||
NoteTag: newNoteTag(db, opts...),
|
||||
NoteToAttachment: newNoteToAttachment(db, opts...),
|
||||
NoteToBoost: newNoteToBoost(db, opts...),
|
||||
NoteToEmote: newNoteToEmote(db, opts...),
|
||||
NoteToFeed: newNoteToFeed(db, opts...),
|
||||
NoteToPing: newNoteToPing(db, opts...),
|
||||
Notification: newNotification(db, opts...),
|
||||
Reaction: newReaction(db, opts...),
|
||||
RemoteServer: newRemoteServer(db, opts...),
|
||||
Role: newRole(db, opts...),
|
||||
|
@ -97,13 +109,17 @@ type Query struct {
|
|||
|
||||
AccessToken accessToken
|
||||
Emote emote
|
||||
Feed feed
|
||||
LoginProcessToken loginProcessToken
|
||||
MediaMetadata mediaMetadata
|
||||
Note note
|
||||
NoteTag noteTag
|
||||
NoteToAttachment noteToAttachment
|
||||
NoteToBoost noteToBoost
|
||||
NoteToEmote noteToEmote
|
||||
NoteToFeed noteToFeed
|
||||
NoteToPing noteToPing
|
||||
Notification notification
|
||||
Reaction reaction
|
||||
RemoteServer remoteServer
|
||||
Role role
|
||||
|
@ -125,13 +141,17 @@ func (q *Query) clone(db *gorm.DB) *Query {
|
|||
db: db,
|
||||
AccessToken: q.AccessToken.clone(db),
|
||||
Emote: q.Emote.clone(db),
|
||||
Feed: q.Feed.clone(db),
|
||||
LoginProcessToken: q.LoginProcessToken.clone(db),
|
||||
MediaMetadata: q.MediaMetadata.clone(db),
|
||||
Note: q.Note.clone(db),
|
||||
NoteTag: q.NoteTag.clone(db),
|
||||
NoteToAttachment: q.NoteToAttachment.clone(db),
|
||||
NoteToBoost: q.NoteToBoost.clone(db),
|
||||
NoteToEmote: q.NoteToEmote.clone(db),
|
||||
NoteToFeed: q.NoteToFeed.clone(db),
|
||||
NoteToPing: q.NoteToPing.clone(db),
|
||||
Notification: q.Notification.clone(db),
|
||||
Reaction: q.Reaction.clone(db),
|
||||
RemoteServer: q.RemoteServer.clone(db),
|
||||
Role: q.Role.clone(db),
|
||||
|
@ -160,13 +180,17 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
|||
db: db,
|
||||
AccessToken: q.AccessToken.replaceDB(db),
|
||||
Emote: q.Emote.replaceDB(db),
|
||||
Feed: q.Feed.replaceDB(db),
|
||||
LoginProcessToken: q.LoginProcessToken.replaceDB(db),
|
||||
MediaMetadata: q.MediaMetadata.replaceDB(db),
|
||||
Note: q.Note.replaceDB(db),
|
||||
NoteTag: q.NoteTag.replaceDB(db),
|
||||
NoteToAttachment: q.NoteToAttachment.replaceDB(db),
|
||||
NoteToBoost: q.NoteToBoost.replaceDB(db),
|
||||
NoteToEmote: q.NoteToEmote.replaceDB(db),
|
||||
NoteToFeed: q.NoteToFeed.replaceDB(db),
|
||||
NoteToPing: q.NoteToPing.replaceDB(db),
|
||||
Notification: q.Notification.replaceDB(db),
|
||||
Reaction: q.Reaction.replaceDB(db),
|
||||
RemoteServer: q.RemoteServer.replaceDB(db),
|
||||
Role: q.Role.replaceDB(db),
|
||||
|
@ -185,13 +209,17 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
|||
type queryCtx struct {
|
||||
AccessToken IAccessTokenDo
|
||||
Emote IEmoteDo
|
||||
Feed IFeedDo
|
||||
LoginProcessToken ILoginProcessTokenDo
|
||||
MediaMetadata IMediaMetadataDo
|
||||
Note INoteDo
|
||||
NoteTag INoteTagDo
|
||||
NoteToAttachment INoteToAttachmentDo
|
||||
NoteToBoost INoteToBoostDo
|
||||
NoteToEmote INoteToEmoteDo
|
||||
NoteToFeed INoteToFeedDo
|
||||
NoteToPing INoteToPingDo
|
||||
Notification INotificationDo
|
||||
Reaction IReactionDo
|
||||
RemoteServer IRemoteServerDo
|
||||
Role IRoleDo
|
||||
|
@ -210,13 +238,17 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
|||
return &queryCtx{
|
||||
AccessToken: q.AccessToken.WithContext(ctx),
|
||||
Emote: q.Emote.WithContext(ctx),
|
||||
Feed: q.Feed.WithContext(ctx),
|
||||
LoginProcessToken: q.LoginProcessToken.WithContext(ctx),
|
||||
MediaMetadata: q.MediaMetadata.WithContext(ctx),
|
||||
Note: q.Note.WithContext(ctx),
|
||||
NoteTag: q.NoteTag.WithContext(ctx),
|
||||
NoteToAttachment: q.NoteToAttachment.WithContext(ctx),
|
||||
NoteToBoost: q.NoteToBoost.WithContext(ctx),
|
||||
NoteToEmote: q.NoteToEmote.WithContext(ctx),
|
||||
NoteToFeed: q.NoteToFeed.WithContext(ctx),
|
||||
NoteToPing: q.NoteToPing.WithContext(ctx),
|
||||
Notification: q.Notification.WithContext(ctx),
|
||||
Reaction: q.Reaction.WithContext(ctx),
|
||||
RemoteServer: q.RemoteServer.WithContext(ctx),
|
||||
Role: q.Role.WithContext(ctx),
|
||||
|
|
|
@ -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.OwnedBy = field.NewString(tableName, "owned_by")
|
||||
_mediaMetadata.OwnedById = field.NewString(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
|
||||
OwnedBy field.String
|
||||
OwnedById field.String
|
||||
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.OwnedBy = field.NewString(table, "owned_by")
|
||||
m.OwnedById = field.NewString(table, "owned_by_id")
|
||||
m.Remote = field.NewBool(table, "remote")
|
||||
m.Location = field.NewString(table, "location")
|
||||
m.Type = field.NewString(table, "type")
|
||||
|
@ -106,7 +106,7 @@ func (m *mediaMetadata) fillFieldMap() {
|
|||
m.fieldMap["created_at"] = m.CreatedAt
|
||||
m.fieldMap["updated_at"] = m.UpdatedAt
|
||||
m.fieldMap["deleted_at"] = m.DeletedAt
|
||||
m.fieldMap["owned_by"] = m.OwnedBy
|
||||
m.fieldMap["owned_by_id"] = m.OwnedById
|
||||
m.fieldMap["remote"] = m.Remote
|
||||
m.fieldMap["location"] = m.Location
|
||||
m.fieldMap["type"] = m.Type
|
||||
|
|
910
storage-new/dbgen/note_to_boosts.gen.go
Normal file
910
storage-new/dbgen/note_to_boosts.gen.go
Normal file
|
@ -0,0 +1,910 @@
|
|||
// 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"
|
||||
|
||||
"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 newNoteToBoost(db *gorm.DB, opts ...gen.DOOption) noteToBoost {
|
||||
_noteToBoost := noteToBoost{}
|
||||
|
||||
_noteToBoost.noteToBoostDo.UseDB(db, opts...)
|
||||
_noteToBoost.noteToBoostDo.UseModel(&models.NoteToBoost{})
|
||||
|
||||
tableName := _noteToBoost.noteToBoostDo.TableName()
|
||||
_noteToBoost.ALL = field.NewAsterisk(tableName)
|
||||
_noteToBoost.ID = field.NewUint(tableName, "id")
|
||||
_noteToBoost.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_noteToBoost.UserId = field.NewString(tableName, "user_id")
|
||||
_noteToBoost.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToBoost.User = noteToBoostBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
Background: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Background", "models.MediaMetadata"),
|
||||
},
|
||||
Banner: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Banner", "models.MediaMetadata"),
|
||||
},
|
||||
RemoteInfo: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.RemoteInfo", "models.UserRemoteLinks"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.RemoteInfo.User", "models.User"),
|
||||
},
|
||||
},
|
||||
InfoFields: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.InfoFields", "models.UserInfoField"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.InfoFields.User", "models.User"),
|
||||
},
|
||||
},
|
||||
BeingTypes: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.BeingTypes", "models.UserToBeing"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.BeingTypes.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Tags", "models.UserToTag"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Tags.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Relations: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Relations", "models.UserToUserRelation"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Relations.User", "models.User"),
|
||||
},
|
||||
TargetUser: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Relations.TargetUser", "models.User"),
|
||||
},
|
||||
},
|
||||
Pronouns: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Pronouns", "models.UserToPronoun"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Pronouns.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Roles: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Roles", "models.UserToRole"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Roles.User", "models.User"),
|
||||
},
|
||||
Role: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.Roles.Role", "models.Role"),
|
||||
},
|
||||
},
|
||||
AuthMethods: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("User.AuthMethods", "models.UserAuthMethod"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("User.AuthMethods.User", "models.User"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToBoost.Note = noteToBoostBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
},
|
||||
AttachmentRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Attachment struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations", "models.NoteToAttachment"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations.Note", "models.Note"),
|
||||
},
|
||||
Attachment: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations.Attachment", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
EmoteRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations", "models.NoteToEmote"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Note", "models.Note"),
|
||||
},
|
||||
Emote: struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
Metadata: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Metadata", "models.MediaMetadata"),
|
||||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
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"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
PingRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations", "models.NoteToPing"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations.Note", "models.Note"),
|
||||
},
|
||||
PingTarget: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations.PingTarget", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Tags", "models.NoteTag"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToBoost.fillFieldMap()
|
||||
|
||||
return _noteToBoost
|
||||
}
|
||||
|
||||
type noteToBoost struct {
|
||||
noteToBoostDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UserId field.String
|
||||
NoteId field.String
|
||||
User noteToBoostBelongsToUser
|
||||
|
||||
Note noteToBoostBelongsToNote
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteToBoost) Table(newTableName string) *noteToBoost {
|
||||
n.noteToBoostDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteToBoost) As(alias string) *noteToBoost {
|
||||
n.noteToBoostDo.DO = *(n.noteToBoostDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteToBoost) updateTableName(table string) *noteToBoost {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewUint(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UserId = field.NewString(table, "user_id")
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteToBoost) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := n.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (n *noteToBoost) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 6)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["user_id"] = n.UserId
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
|
||||
}
|
||||
|
||||
func (n noteToBoost) clone(db *gorm.DB) noteToBoost {
|
||||
n.noteToBoostDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToBoost) replaceDB(db *gorm.DB) noteToBoost {
|
||||
n.noteToBoostDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
Background struct {
|
||||
field.RelationField
|
||||
}
|
||||
Banner struct {
|
||||
field.RelationField
|
||||
}
|
||||
RemoteInfo struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
InfoFields struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
BeingTypes struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Relations struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Pronouns struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Roles struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
AuthMethods struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUser) Where(conds ...field.Expr) *noteToBoostBelongsToUser {
|
||||
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 noteToBoostBelongsToUser) WithContext(ctx context.Context) *noteToBoostBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUser) Session(session *gorm.Session) *noteToBoostBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUser) Model(m *models.NoteToBoost) *noteToBoostBelongsToUserTx {
|
||||
return ¬eToBoostBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Append(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Replace(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Delete(values ...*models.User) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
}
|
||||
AttachmentRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Attachment struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
EmoteRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNote) Where(conds ...field.Expr) *noteToBoostBelongsToNote {
|
||||
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 noteToBoostBelongsToNote) WithContext(ctx context.Context) *noteToBoostBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNote) Session(session *gorm.Session) *noteToBoostBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNote) Model(m *models.NoteToBoost) *noteToBoostBelongsToNoteTx {
|
||||
return ¬eToBoostBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToBoostBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Append(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Replace(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Delete(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToBoostBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToBoostDo struct{ gen.DO }
|
||||
|
||||
type INoteToBoostDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteToBoostDo
|
||||
WithContext(ctx context.Context) INoteToBoostDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteToBoostDo
|
||||
WriteDB() INoteToBoostDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteToBoostDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteToBoostDo
|
||||
Not(conds ...gen.Condition) INoteToBoostDo
|
||||
Or(conds ...gen.Condition) INoteToBoostDo
|
||||
Select(conds ...field.Expr) INoteToBoostDo
|
||||
Where(conds ...gen.Condition) INoteToBoostDo
|
||||
Order(conds ...field.Expr) INoteToBoostDo
|
||||
Distinct(cols ...field.Expr) INoteToBoostDo
|
||||
Omit(cols ...field.Expr) INoteToBoostDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteToBoostDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteToBoostDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteToBoostDo
|
||||
Group(cols ...field.Expr) INoteToBoostDo
|
||||
Having(conds ...gen.Condition) INoteToBoostDo
|
||||
Limit(limit int) INoteToBoostDo
|
||||
Offset(offset int) INoteToBoostDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToBoostDo
|
||||
Unscoped() INoteToBoostDo
|
||||
Create(values ...*models.NoteToBoost) error
|
||||
CreateInBatches(values []*models.NoteToBoost, batchSize int) error
|
||||
Save(values ...*models.NoteToBoost) error
|
||||
First() (*models.NoteToBoost, error)
|
||||
Take() (*models.NoteToBoost, error)
|
||||
Last() (*models.NoteToBoost, error)
|
||||
Find() ([]*models.NoteToBoost, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToBoost, err error)
|
||||
FindInBatches(result *[]*models.NoteToBoost, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteToBoost) (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) INoteToBoostDo
|
||||
Assign(attrs ...field.AssignExpr) INoteToBoostDo
|
||||
Joins(fields ...field.RelationField) INoteToBoostDo
|
||||
Preload(fields ...field.RelationField) INoteToBoostDo
|
||||
FirstOrInit() (*models.NoteToBoost, error)
|
||||
FirstOrCreate() (*models.NoteToBoost, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToBoost, 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) INoteToBoostDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Debug() INoteToBoostDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) WithContext(ctx context.Context) INoteToBoostDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) ReadDB() INoteToBoostDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) WriteDB() INoteToBoostDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Session(config *gorm.Session) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Clauses(conds ...clause.Expression) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Returning(value interface{}, columns ...string) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Not(conds ...gen.Condition) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Or(conds ...gen.Condition) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Select(conds ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Where(conds ...gen.Condition) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Order(conds ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Distinct(cols ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Omit(cols ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Join(table schema.Tabler, on ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Group(cols ...field.Expr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Having(conds ...gen.Condition) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Limit(limit int) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Offset(offset int) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Unscoped() INoteToBoostDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Create(values ...*models.NoteToBoost) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) CreateInBatches(values []*models.NoteToBoost, batchSize int) error {
|
||||
return n.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (n noteToBoostDo) Save(values ...*models.NoteToBoost) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) First() (*models.NoteToBoost, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToBoost), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Take() (*models.NoteToBoost, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToBoost), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Last() (*models.NoteToBoost, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToBoost), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Find() ([]*models.NoteToBoost, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteToBoost), err
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToBoost, err error) {
|
||||
buf := make([]*models.NoteToBoost, 0, batchSize)
|
||||
err = n.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) FindInBatches(result *[]*models.NoteToBoost, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Attrs(attrs ...field.AssignExpr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Assign(attrs ...field.AssignExpr) INoteToBoostDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Joins(fields ...field.RelationField) INoteToBoostDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Preload(fields ...field.RelationField) INoteToBoostDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) FirstOrInit() (*models.NoteToBoost, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToBoost), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) FirstOrCreate() (*models.NoteToBoost, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToBoost), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) FindByPage(offset int, limit int) (result []*models.NoteToBoost, count int64, err error) {
|
||||
result, err = n.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = n.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = n.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = n.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteToBoostDo) Delete(models ...*models.NoteToBoost) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteToBoostDo) withDO(do gen.Dao) *noteToBoostDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
889
storage-new/dbgen/note_to_feeds.gen.go
Normal file
889
storage-new/dbgen/note_to_feeds.gen.go
Normal file
|
@ -0,0 +1,889 @@
|
|||
// 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"
|
||||
|
||||
"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 newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
||||
_noteToFeed := noteToFeed{}
|
||||
|
||||
_noteToFeed.noteToFeedDo.UseDB(db, opts...)
|
||||
_noteToFeed.noteToFeedDo.UseModel(&models.NoteToFeed{})
|
||||
|
||||
tableName := _noteToFeed.noteToFeedDo.TableName()
|
||||
_noteToFeed.ALL = field.NewAsterisk(tableName)
|
||||
_noteToFeed.ID = field.NewUint64(tableName, "id")
|
||||
_noteToFeed.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_noteToFeed.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToFeed.Note = noteToFeedBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
Creator: struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
Background struct {
|
||||
field.RelationField
|
||||
}
|
||||
Banner struct {
|
||||
field.RelationField
|
||||
}
|
||||
RemoteInfo struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
InfoFields struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
BeingTypes struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Relations struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Pronouns struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Roles struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
AuthMethods struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator", "models.User"),
|
||||
Icon: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Icon", "models.MediaMetadata"),
|
||||
},
|
||||
Background: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Background", "models.MediaMetadata"),
|
||||
},
|
||||
Banner: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Banner", "models.MediaMetadata"),
|
||||
},
|
||||
RemoteInfo: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.RemoteInfo", "models.UserRemoteLinks"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.RemoteInfo.User", "models.User"),
|
||||
},
|
||||
},
|
||||
InfoFields: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.InfoFields", "models.UserInfoField"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.InfoFields.User", "models.User"),
|
||||
},
|
||||
},
|
||||
BeingTypes: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.BeingTypes", "models.UserToBeing"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.BeingTypes.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Tags", "models.UserToTag"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Tags.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Relations: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Relations", "models.UserToUserRelation"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Relations.User", "models.User"),
|
||||
},
|
||||
TargetUser: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Relations.TargetUser", "models.User"),
|
||||
},
|
||||
},
|
||||
Pronouns: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Pronouns", "models.UserToPronoun"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Pronouns.User", "models.User"),
|
||||
},
|
||||
},
|
||||
Roles: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Roles", "models.UserToRole"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Roles.User", "models.User"),
|
||||
},
|
||||
Role: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.Roles.Role", "models.Role"),
|
||||
},
|
||||
},
|
||||
AuthMethods: struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.AuthMethods", "models.UserAuthMethod"),
|
||||
User: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Creator.AuthMethods.User", "models.User"),
|
||||
},
|
||||
},
|
||||
},
|
||||
AttachmentRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Attachment struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations", "models.NoteToAttachment"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations.Note", "models.Note"),
|
||||
},
|
||||
Attachment: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.AttachmentRelations.Attachment", "models.MediaMetadata"),
|
||||
},
|
||||
},
|
||||
EmoteRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations", "models.NoteToEmote"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Note", "models.Note"),
|
||||
},
|
||||
Emote: struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote", "models.Emote"),
|
||||
Metadata: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Metadata", "models.MediaMetadata"),
|
||||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
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"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
PingRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations", "models.NoteToPing"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations.Note", "models.Note"),
|
||||
},
|
||||
PingTarget: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.PingRelations.PingTarget", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Tags", "models.NoteTag"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.Tags.Note", "models.Note"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToFeed.fillFieldMap()
|
||||
|
||||
return _noteToFeed
|
||||
}
|
||||
|
||||
type noteToFeed struct {
|
||||
noteToFeedDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
NoteId field.String
|
||||
Note noteToFeedBelongsToNote
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteToFeed) Table(newTableName string) *noteToFeed {
|
||||
n.noteToFeedDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteToFeed) As(alias string) *noteToFeed {
|
||||
n.noteToFeedDo.DO = *(n.noteToFeedDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteToFeed) updateTableName(table string) *noteToFeed {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewUint64(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteToFeed) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := n.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (n *noteToFeed) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 4)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
|
||||
}
|
||||
|
||||
func (n noteToFeed) clone(db *gorm.DB) noteToFeed {
|
||||
n.noteToFeedDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToFeed) replaceDB(db *gorm.DB) noteToFeed {
|
||||
n.noteToFeedDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteToFeedBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Creator struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
Background struct {
|
||||
field.RelationField
|
||||
}
|
||||
Banner struct {
|
||||
field.RelationField
|
||||
}
|
||||
RemoteInfo struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
InfoFields struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
BeingTypes struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Relations struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
TargetUser struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Pronouns struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Roles struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
Role struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
AuthMethods struct {
|
||||
field.RelationField
|
||||
User struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
AttachmentRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Attachment struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
EmoteRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
Icon struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNote) Where(conds ...field.Expr) *noteToFeedBelongsToNote {
|
||||
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 noteToFeedBelongsToNote) WithContext(ctx context.Context) *noteToFeedBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNote) Session(session *gorm.Session) *noteToFeedBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNote) Model(m *models.NoteToFeed) *noteToFeedBelongsToNoteTx {
|
||||
return ¬eToFeedBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToFeedBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Append(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Replace(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Delete(values ...*models.Note) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToFeedDo struct{ gen.DO }
|
||||
|
||||
type INoteToFeedDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteToFeedDo
|
||||
WithContext(ctx context.Context) INoteToFeedDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteToFeedDo
|
||||
WriteDB() INoteToFeedDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteToFeedDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteToFeedDo
|
||||
Not(conds ...gen.Condition) INoteToFeedDo
|
||||
Or(conds ...gen.Condition) INoteToFeedDo
|
||||
Select(conds ...field.Expr) INoteToFeedDo
|
||||
Where(conds ...gen.Condition) INoteToFeedDo
|
||||
Order(conds ...field.Expr) INoteToFeedDo
|
||||
Distinct(cols ...field.Expr) INoteToFeedDo
|
||||
Omit(cols ...field.Expr) INoteToFeedDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteToFeedDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteToFeedDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteToFeedDo
|
||||
Group(cols ...field.Expr) INoteToFeedDo
|
||||
Having(conds ...gen.Condition) INoteToFeedDo
|
||||
Limit(limit int) INoteToFeedDo
|
||||
Offset(offset int) INoteToFeedDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToFeedDo
|
||||
Unscoped() INoteToFeedDo
|
||||
Create(values ...*models.NoteToFeed) error
|
||||
CreateInBatches(values []*models.NoteToFeed, batchSize int) error
|
||||
Save(values ...*models.NoteToFeed) error
|
||||
First() (*models.NoteToFeed, error)
|
||||
Take() (*models.NoteToFeed, error)
|
||||
Last() (*models.NoteToFeed, error)
|
||||
Find() ([]*models.NoteToFeed, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToFeed, err error)
|
||||
FindInBatches(result *[]*models.NoteToFeed, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteToFeed) (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) INoteToFeedDo
|
||||
Assign(attrs ...field.AssignExpr) INoteToFeedDo
|
||||
Joins(fields ...field.RelationField) INoteToFeedDo
|
||||
Preload(fields ...field.RelationField) INoteToFeedDo
|
||||
FirstOrInit() (*models.NoteToFeed, error)
|
||||
FirstOrCreate() (*models.NoteToFeed, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToFeed, 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) INoteToFeedDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Debug() INoteToFeedDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) WithContext(ctx context.Context) INoteToFeedDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) ReadDB() INoteToFeedDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) WriteDB() INoteToFeedDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Session(config *gorm.Session) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Clauses(conds ...clause.Expression) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Returning(value interface{}, columns ...string) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Not(conds ...gen.Condition) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Or(conds ...gen.Condition) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Select(conds ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Where(conds ...gen.Condition) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Order(conds ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Distinct(cols ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Omit(cols ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Join(table schema.Tabler, on ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Group(cols ...field.Expr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Having(conds ...gen.Condition) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Limit(limit int) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Offset(offset int) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Unscoped() INoteToFeedDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Create(values ...*models.NoteToFeed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) CreateInBatches(values []*models.NoteToFeed, batchSize int) error {
|
||||
return n.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (n noteToFeedDo) Save(values ...*models.NoteToFeed) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) First() (*models.NoteToFeed, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToFeed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Take() (*models.NoteToFeed, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToFeed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Last() (*models.NoteToFeed, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToFeed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Find() ([]*models.NoteToFeed, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteToFeed), err
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToFeed, err error) {
|
||||
buf := make([]*models.NoteToFeed, 0, batchSize)
|
||||
err = n.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) FindInBatches(result *[]*models.NoteToFeed, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Attrs(attrs ...field.AssignExpr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Assign(attrs ...field.AssignExpr) INoteToFeedDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Joins(fields ...field.RelationField) INoteToFeedDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Preload(fields ...field.RelationField) INoteToFeedDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) FirstOrInit() (*models.NoteToFeed, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToFeed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) FirstOrCreate() (*models.NoteToFeed, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToFeed), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) FindByPage(offset int, limit int) (result []*models.NoteToFeed, count int64, err error) {
|
||||
result, err = n.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = n.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = n.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = n.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteToFeedDo) Delete(models ...*models.NoteToFeed) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteToFeedDo) withDO(do gen.Dao) *noteToFeedDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
1067
storage-new/dbgen/notifications.gen.go
Normal file
1067
storage-new/dbgen/notifications.gen.go
Normal file
File diff suppressed because it is too large
Load diff
|
@ -33,7 +33,7 @@ func newRemoteServer(db *gorm.DB, opts ...gen.DOOption) remoteServer {
|
|||
_remoteServer.ServerType = field.NewField(tableName, "server_type")
|
||||
_remoteServer.Domain = field.NewString(tableName, "domain")
|
||||
_remoteServer.Name = field.NewString(tableName, "name")
|
||||
_remoteServer.IconId = field.NewString(tableName, "icon_id")
|
||||
_remoteServer.IconId = field.NewField(tableName, "icon_id")
|
||||
_remoteServer.IsSelf = field.NewBool(tableName, "is_self")
|
||||
_remoteServer.Icon = remoteServerBelongsToIcon{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
@ -57,7 +57,7 @@ type remoteServer struct {
|
|||
ServerType field.Field
|
||||
Domain field.String
|
||||
Name field.String
|
||||
IconId field.String
|
||||
IconId field.Field
|
||||
IsSelf field.Bool
|
||||
Icon remoteServerBelongsToIcon
|
||||
|
||||
|
@ -83,7 +83,7 @@ func (r *remoteServer) updateTableName(table string) *remoteServer {
|
|||
r.ServerType = field.NewField(table, "server_type")
|
||||
r.Domain = field.NewString(table, "domain")
|
||||
r.Name = field.NewString(table, "name")
|
||||
r.IconId = field.NewString(table, "icon_id")
|
||||
r.IconId = field.NewField(table, "icon_id")
|
||||
r.IsSelf = field.NewBool(table, "is_self")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
|
|
@ -6,6 +6,7 @@ package dbgen
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
"gorm.io/gorm"
|
||||
|
@ -1346,6 +1347,25 @@ type IUserDo interface {
|
|||
Returning(value interface{}, columns ...string) IUserDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
|
||||
GetByUsername(username string) (result *models.User, err error)
|
||||
}
|
||||
|
||||
// Get a user by a username
|
||||
//
|
||||
// SELECT * FROM @@table WHERE username = @username 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 = ? LIMIT 1 ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) Debug() IUserDo {
|
||||
|
|
Loading…
Reference in a new issue