Update new storage types and regenerate
This commit is contained in:
parent
0932f19f71
commit
41e432b56e
28 changed files with 6561 additions and 23 deletions
660
storage-new/dbgen/user_to_pronouns.gen.go
Normal file
660
storage-new/dbgen/user_to_pronouns.gen.go
Normal file
|
@ -0,0 +1,660 @@
|
|||
// 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 newUserToPronoun(db *gorm.DB, opts ...gen.DOOption) userToPronoun {
|
||||
_userToPronoun := userToPronoun{}
|
||||
|
||||
_userToPronoun.userToPronounDo.UseDB(db, opts...)
|
||||
_userToPronoun.userToPronounDo.UseModel(&models.UserToPronoun{})
|
||||
|
||||
tableName := _userToPronoun.userToPronounDo.TableName()
|
||||
_userToPronoun.ALL = field.NewAsterisk(tableName)
|
||||
_userToPronoun.UserId = field.NewString(tableName, "user_id")
|
||||
_userToPronoun.Pronoung = field.NewString(tableName, "pronoung")
|
||||
_userToPronoun.User = userToPronounBelongsToUser{
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_userToPronoun.fillFieldMap()
|
||||
|
||||
return _userToPronoun
|
||||
}
|
||||
|
||||
type userToPronoun struct {
|
||||
userToPronounDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
Pronoung field.String
|
||||
User userToPronounBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userToPronoun) Table(newTableName string) *userToPronoun {
|
||||
u.userToPronounDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userToPronoun) As(alias string) *userToPronoun {
|
||||
u.userToPronounDo.DO = *(u.userToPronounDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userToPronoun) updateTableName(table string) *userToPronoun {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.Pronoung = field.NewString(table, "pronoung")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userToPronoun) 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 *userToPronoun) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 3)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["pronoung"] = u.Pronoung
|
||||
|
||||
}
|
||||
|
||||
func (u userToPronoun) clone(db *gorm.DB) userToPronoun {
|
||||
u.userToPronounDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToPronoun) replaceDB(db *gorm.DB) userToPronoun {
|
||||
u.userToPronounDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userToPronounBelongsToUser 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 userToPronounBelongsToUser) Where(conds ...field.Expr) *userToPronounBelongsToUser {
|
||||
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 userToPronounBelongsToUser) WithContext(ctx context.Context) *userToPronounBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToPronounBelongsToUser) Session(session *gorm.Session) *userToPronounBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToPronounBelongsToUser) Model(m *models.UserToPronoun) *userToPronounBelongsToUserTx {
|
||||
return &userToPronounBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToPronounBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToPronounBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToPronounBelongsToUserTx) 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 userToPronounBelongsToUserTx) 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 userToPronounBelongsToUserTx) 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 userToPronounBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToPronounBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToPronounDo struct{ gen.DO }
|
||||
|
||||
type IUserToPronounDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserToPronounDo
|
||||
WithContext(ctx context.Context) IUserToPronounDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserToPronounDo
|
||||
WriteDB() IUserToPronounDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserToPronounDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserToPronounDo
|
||||
Not(conds ...gen.Condition) IUserToPronounDo
|
||||
Or(conds ...gen.Condition) IUserToPronounDo
|
||||
Select(conds ...field.Expr) IUserToPronounDo
|
||||
Where(conds ...gen.Condition) IUserToPronounDo
|
||||
Order(conds ...field.Expr) IUserToPronounDo
|
||||
Distinct(cols ...field.Expr) IUserToPronounDo
|
||||
Omit(cols ...field.Expr) IUserToPronounDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserToPronounDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserToPronounDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserToPronounDo
|
||||
Group(cols ...field.Expr) IUserToPronounDo
|
||||
Having(conds ...gen.Condition) IUserToPronounDo
|
||||
Limit(limit int) IUserToPronounDo
|
||||
Offset(offset int) IUserToPronounDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToPronounDo
|
||||
Unscoped() IUserToPronounDo
|
||||
Create(values ...*models.UserToPronoun) error
|
||||
CreateInBatches(values []*models.UserToPronoun, batchSize int) error
|
||||
Save(values ...*models.UserToPronoun) error
|
||||
First() (*models.UserToPronoun, error)
|
||||
Take() (*models.UserToPronoun, error)
|
||||
Last() (*models.UserToPronoun, error)
|
||||
Find() ([]*models.UserToPronoun, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToPronoun, err error)
|
||||
FindInBatches(result *[]*models.UserToPronoun, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserToPronoun) (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) IUserToPronounDo
|
||||
Assign(attrs ...field.AssignExpr) IUserToPronounDo
|
||||
Joins(fields ...field.RelationField) IUserToPronounDo
|
||||
Preload(fields ...field.RelationField) IUserToPronounDo
|
||||
FirstOrInit() (*models.UserToPronoun, error)
|
||||
FirstOrCreate() (*models.UserToPronoun, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToPronoun, 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) IUserToPronounDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Debug() IUserToPronounDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userToPronounDo) WithContext(ctx context.Context) IUserToPronounDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) ReadDB() IUserToPronounDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) WriteDB() IUserToPronounDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Session(config *gorm.Session) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Clauses(conds ...clause.Expression) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Returning(value interface{}, columns ...string) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Not(conds ...gen.Condition) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Or(conds ...gen.Condition) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Select(conds ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Where(conds ...gen.Condition) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Order(conds ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Distinct(cols ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Omit(cols ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Join(table schema.Tabler, on ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Group(cols ...field.Expr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Having(conds ...gen.Condition) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Limit(limit int) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Offset(offset int) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Unscoped() IUserToPronounDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Create(values ...*models.UserToPronoun) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) CreateInBatches(values []*models.UserToPronoun, 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 userToPronounDo) Save(values ...*models.UserToPronoun) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) First() (*models.UserToPronoun, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToPronoun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Take() (*models.UserToPronoun, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToPronoun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Last() (*models.UserToPronoun, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToPronoun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Find() ([]*models.UserToPronoun, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserToPronoun), err
|
||||
}
|
||||
|
||||
func (u userToPronounDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToPronoun, err error) {
|
||||
buf := make([]*models.UserToPronoun, 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 userToPronounDo) FindInBatches(result *[]*models.UserToPronoun, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Attrs(attrs ...field.AssignExpr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Assign(attrs ...field.AssignExpr) IUserToPronounDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Joins(fields ...field.RelationField) IUserToPronounDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Preload(fields ...field.RelationField) IUserToPronounDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToPronounDo) FirstOrInit() (*models.UserToPronoun, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToPronoun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToPronounDo) FirstOrCreate() (*models.UserToPronoun, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToPronoun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToPronounDo) FindByPage(offset int, limit int) (result []*models.UserToPronoun, 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 userToPronounDo) 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 userToPronounDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userToPronounDo) Delete(models ...*models.UserToPronoun) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userToPronounDo) withDO(do gen.Dao) *userToPronounDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue