chore(new-storage): Auto-generate new storage impl
Some checks are pending
/ test (push) Waiting to run
Some checks are pending
/ test (push) Waiting to run
This commit is contained in:
parent
8ffd6d0050
commit
68859642f3
19 changed files with 10441 additions and 0 deletions
560
storage-new/dbgen/emotes.gen.go
Normal file
560
storage-new/dbgen/emotes.gen.go
Normal file
|
@ -0,0 +1,560 @@
|
|||
// 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 newEmote(db *gorm.DB, opts ...gen.DOOption) emote {
|
||||
_emote := emote{}
|
||||
|
||||
_emote.emoteDo.UseDB(db, opts...)
|
||||
_emote.emoteDo.UseModel(&models.Emote{})
|
||||
|
||||
tableName := _emote.emoteDo.TableName()
|
||||
_emote.ALL = field.NewAsterisk(tableName)
|
||||
_emote.ID = field.NewUint(tableName, "id")
|
||||
_emote.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_emote.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_emote.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_emote.MetadataId = field.NewString(tableName, "metadata_id")
|
||||
_emote.Name = field.NewString(tableName, "name")
|
||||
_emote.ServerId = field.NewUint(tableName, "server_id")
|
||||
_emote.Metadata = emoteBelongsToMetadata{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Metadata", "models.MediaMetadata"),
|
||||
}
|
||||
|
||||
_emote.Server = emoteBelongsToServer{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Server", "models.RemoteServer"),
|
||||
}
|
||||
|
||||
_emote.fillFieldMap()
|
||||
|
||||
return _emote
|
||||
}
|
||||
|
||||
type emote struct {
|
||||
emoteDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
MetadataId field.String
|
||||
Name field.String
|
||||
ServerId field.Uint
|
||||
Metadata emoteBelongsToMetadata
|
||||
|
||||
Server emoteBelongsToServer
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (e emote) Table(newTableName string) *emote {
|
||||
e.emoteDo.UseTable(newTableName)
|
||||
return e.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (e emote) As(alias string) *emote {
|
||||
e.emoteDo.DO = *(e.emoteDo.As(alias).(*gen.DO))
|
||||
return e.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (e *emote) updateTableName(table string) *emote {
|
||||
e.ALL = field.NewAsterisk(table)
|
||||
e.ID = field.NewUint(table, "id")
|
||||
e.CreatedAt = field.NewTime(table, "created_at")
|
||||
e.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
e.DeletedAt = field.NewField(table, "deleted_at")
|
||||
e.MetadataId = field.NewString(table, "metadata_id")
|
||||
e.Name = field.NewString(table, "name")
|
||||
e.ServerId = field.NewUint(table, "server_id")
|
||||
|
||||
e.fillFieldMap()
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *emote) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := e.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (e *emote) fillFieldMap() {
|
||||
e.fieldMap = make(map[string]field.Expr, 9)
|
||||
e.fieldMap["id"] = e.ID
|
||||
e.fieldMap["created_at"] = e.CreatedAt
|
||||
e.fieldMap["updated_at"] = e.UpdatedAt
|
||||
e.fieldMap["deleted_at"] = e.DeletedAt
|
||||
e.fieldMap["metadata_id"] = e.MetadataId
|
||||
e.fieldMap["name"] = e.Name
|
||||
e.fieldMap["server_id"] = e.ServerId
|
||||
|
||||
}
|
||||
|
||||
func (e emote) clone(db *gorm.DB) emote {
|
||||
e.emoteDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e emote) replaceDB(db *gorm.DB) emote {
|
||||
e.emoteDo.ReplaceDB(db)
|
||||
return e
|
||||
}
|
||||
|
||||
type emoteBelongsToMetadata struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadata) Where(conds ...field.Expr) *emoteBelongsToMetadata {
|
||||
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 emoteBelongsToMetadata) WithContext(ctx context.Context) *emoteBelongsToMetadata {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadata) Session(session *gorm.Session) *emoteBelongsToMetadata {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadata) Model(m *models.Emote) *emoteBelongsToMetadataTx {
|
||||
return &emoteBelongsToMetadataTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type emoteBelongsToMetadataTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Find() (result *models.MediaMetadata, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Append(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Replace(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Delete(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a emoteBelongsToMetadataTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type emoteBelongsToServer struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServer) Where(conds ...field.Expr) *emoteBelongsToServer {
|
||||
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 emoteBelongsToServer) WithContext(ctx context.Context) *emoteBelongsToServer {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServer) Session(session *gorm.Session) *emoteBelongsToServer {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServer) Model(m *models.Emote) *emoteBelongsToServerTx {
|
||||
return &emoteBelongsToServerTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type emoteBelongsToServerTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a emoteBelongsToServerTx) Find() (result *models.RemoteServer, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Append(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Replace(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Delete(values ...*models.RemoteServer) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a emoteBelongsToServerTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type emoteDo struct{ gen.DO }
|
||||
|
||||
type IEmoteDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IEmoteDo
|
||||
WithContext(ctx context.Context) IEmoteDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IEmoteDo
|
||||
WriteDB() IEmoteDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IEmoteDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IEmoteDo
|
||||
Not(conds ...gen.Condition) IEmoteDo
|
||||
Or(conds ...gen.Condition) IEmoteDo
|
||||
Select(conds ...field.Expr) IEmoteDo
|
||||
Where(conds ...gen.Condition) IEmoteDo
|
||||
Order(conds ...field.Expr) IEmoteDo
|
||||
Distinct(cols ...field.Expr) IEmoteDo
|
||||
Omit(cols ...field.Expr) IEmoteDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IEmoteDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IEmoteDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IEmoteDo
|
||||
Group(cols ...field.Expr) IEmoteDo
|
||||
Having(conds ...gen.Condition) IEmoteDo
|
||||
Limit(limit int) IEmoteDo
|
||||
Offset(offset int) IEmoteDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IEmoteDo
|
||||
Unscoped() IEmoteDo
|
||||
Create(values ...*models.Emote) error
|
||||
CreateInBatches(values []*models.Emote, batchSize int) error
|
||||
Save(values ...*models.Emote) error
|
||||
First() (*models.Emote, error)
|
||||
Take() (*models.Emote, error)
|
||||
Last() (*models.Emote, error)
|
||||
Find() ([]*models.Emote, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Emote, err error)
|
||||
FindInBatches(result *[]*models.Emote, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.Emote) (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) IEmoteDo
|
||||
Assign(attrs ...field.AssignExpr) IEmoteDo
|
||||
Joins(fields ...field.RelationField) IEmoteDo
|
||||
Preload(fields ...field.RelationField) IEmoteDo
|
||||
FirstOrInit() (*models.Emote, error)
|
||||
FirstOrCreate() (*models.Emote, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Emote, 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) IEmoteDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (e emoteDo) Debug() IEmoteDo {
|
||||
return e.withDO(e.DO.Debug())
|
||||
}
|
||||
|
||||
func (e emoteDo) WithContext(ctx context.Context) IEmoteDo {
|
||||
return e.withDO(e.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (e emoteDo) ReadDB() IEmoteDo {
|
||||
return e.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (e emoteDo) WriteDB() IEmoteDo {
|
||||
return e.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (e emoteDo) Session(config *gorm.Session) IEmoteDo {
|
||||
return e.withDO(e.DO.Session(config))
|
||||
}
|
||||
|
||||
func (e emoteDo) Clauses(conds ...clause.Expression) IEmoteDo {
|
||||
return e.withDO(e.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Returning(value interface{}, columns ...string) IEmoteDo {
|
||||
return e.withDO(e.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Not(conds ...gen.Condition) IEmoteDo {
|
||||
return e.withDO(e.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Or(conds ...gen.Condition) IEmoteDo {
|
||||
return e.withDO(e.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Select(conds ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Where(conds ...gen.Condition) IEmoteDo {
|
||||
return e.withDO(e.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Order(conds ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Distinct(cols ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Omit(cols ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Join(table schema.Tabler, on ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (e emoteDo) LeftJoin(table schema.Tabler, on ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (e emoteDo) RightJoin(table schema.Tabler, on ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Group(cols ...field.Expr) IEmoteDo {
|
||||
return e.withDO(e.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Having(conds ...gen.Condition) IEmoteDo {
|
||||
return e.withDO(e.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Limit(limit int) IEmoteDo {
|
||||
return e.withDO(e.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (e emoteDo) Offset(offset int) IEmoteDo {
|
||||
return e.withDO(e.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (e emoteDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IEmoteDo {
|
||||
return e.withDO(e.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Unscoped() IEmoteDo {
|
||||
return e.withDO(e.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (e emoteDo) Create(values ...*models.Emote) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return e.DO.Create(values)
|
||||
}
|
||||
|
||||
func (e emoteDo) CreateInBatches(values []*models.Emote, batchSize int) error {
|
||||
return e.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 (e emoteDo) Save(values ...*models.Emote) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return e.DO.Save(values)
|
||||
}
|
||||
|
||||
func (e emoteDo) First() (*models.Emote, error) {
|
||||
if result, err := e.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Emote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e emoteDo) Take() (*models.Emote, error) {
|
||||
if result, err := e.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Emote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e emoteDo) Last() (*models.Emote, error) {
|
||||
if result, err := e.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Emote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e emoteDo) Find() ([]*models.Emote, error) {
|
||||
result, err := e.DO.Find()
|
||||
return result.([]*models.Emote), err
|
||||
}
|
||||
|
||||
func (e emoteDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Emote, err error) {
|
||||
buf := make([]*models.Emote, 0, batchSize)
|
||||
err = e.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 (e emoteDo) FindInBatches(result *[]*models.Emote, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return e.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (e emoteDo) Attrs(attrs ...field.AssignExpr) IEmoteDo {
|
||||
return e.withDO(e.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Assign(attrs ...field.AssignExpr) IEmoteDo {
|
||||
return e.withDO(e.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (e emoteDo) Joins(fields ...field.RelationField) IEmoteDo {
|
||||
for _, _f := range fields {
|
||||
e = *e.withDO(e.DO.Joins(_f))
|
||||
}
|
||||
return &e
|
||||
}
|
||||
|
||||
func (e emoteDo) Preload(fields ...field.RelationField) IEmoteDo {
|
||||
for _, _f := range fields {
|
||||
e = *e.withDO(e.DO.Preload(_f))
|
||||
}
|
||||
return &e
|
||||
}
|
||||
|
||||
func (e emoteDo) FirstOrInit() (*models.Emote, error) {
|
||||
if result, err := e.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Emote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e emoteDo) FirstOrCreate() (*models.Emote, error) {
|
||||
if result, err := e.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Emote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (e emoteDo) FindByPage(offset int, limit int) (result []*models.Emote, count int64, err error) {
|
||||
result, err = e.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 = e.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (e emoteDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = e.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = e.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (e emoteDo) Scan(result interface{}) (err error) {
|
||||
return e.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (e emoteDo) Delete(models ...*models.Emote) (result gen.ResultInfo, err error) {
|
||||
return e.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (e *emoteDo) withDO(do gen.Dao) *emoteDo {
|
||||
e.DO = *do.(*gen.DO)
|
||||
return e
|
||||
}
|
239
storage-new/dbgen/gen.go
Normal file
239
storage-new/dbgen/gen.go
Normal file
|
@ -0,0 +1,239 @@
|
|||
// 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"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"gorm.io/gen"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
)
|
||||
|
||||
var (
|
||||
Q = new(Query)
|
||||
Emote *emote
|
||||
MediaMetadata *mediaMetadata
|
||||
Note *note
|
||||
NoteTag *noteTag
|
||||
NoteToAttachment *noteToAttachment
|
||||
NoteToEmote *noteToEmote
|
||||
NoteToPing *noteToPing
|
||||
Reaction *reaction
|
||||
RemoteServer *remoteServer
|
||||
Role *role
|
||||
User *user
|
||||
UserAuthMethod *userAuthMethod
|
||||
UserInfoField *userInfoField
|
||||
UserRemoteLinks *userRemoteLinks
|
||||
UserToBeing *userToBeing
|
||||
UserToRole *userToRole
|
||||
UserToTag *userToTag
|
||||
UserToUserRelation *userToUserRelation
|
||||
)
|
||||
|
||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
*Q = *Use(db, opts...)
|
||||
Emote = &Q.Emote
|
||||
MediaMetadata = &Q.MediaMetadata
|
||||
Note = &Q.Note
|
||||
NoteTag = &Q.NoteTag
|
||||
NoteToAttachment = &Q.NoteToAttachment
|
||||
NoteToEmote = &Q.NoteToEmote
|
||||
NoteToPing = &Q.NoteToPing
|
||||
Reaction = &Q.Reaction
|
||||
RemoteServer = &Q.RemoteServer
|
||||
Role = &Q.Role
|
||||
User = &Q.User
|
||||
UserAuthMethod = &Q.UserAuthMethod
|
||||
UserInfoField = &Q.UserInfoField
|
||||
UserRemoteLinks = &Q.UserRemoteLinks
|
||||
UserToBeing = &Q.UserToBeing
|
||||
UserToRole = &Q.UserToRole
|
||||
UserToTag = &Q.UserToTag
|
||||
UserToUserRelation = &Q.UserToUserRelation
|
||||
}
|
||||
|
||||
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Emote: newEmote(db, opts...),
|
||||
MediaMetadata: newMediaMetadata(db, opts...),
|
||||
Note: newNote(db, opts...),
|
||||
NoteTag: newNoteTag(db, opts...),
|
||||
NoteToAttachment: newNoteToAttachment(db, opts...),
|
||||
NoteToEmote: newNoteToEmote(db, opts...),
|
||||
NoteToPing: newNoteToPing(db, opts...),
|
||||
Reaction: newReaction(db, opts...),
|
||||
RemoteServer: newRemoteServer(db, opts...),
|
||||
Role: newRole(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserAuthMethod: newUserAuthMethod(db, opts...),
|
||||
UserInfoField: newUserInfoField(db, opts...),
|
||||
UserRemoteLinks: newUserRemoteLinks(db, opts...),
|
||||
UserToBeing: newUserToBeing(db, opts...),
|
||||
UserToRole: newUserToRole(db, opts...),
|
||||
UserToTag: newUserToTag(db, opts...),
|
||||
UserToUserRelation: newUserToUserRelation(db, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
Emote emote
|
||||
MediaMetadata mediaMetadata
|
||||
Note note
|
||||
NoteTag noteTag
|
||||
NoteToAttachment noteToAttachment
|
||||
NoteToEmote noteToEmote
|
||||
NoteToPing noteToPing
|
||||
Reaction reaction
|
||||
RemoteServer remoteServer
|
||||
Role role
|
||||
User user
|
||||
UserAuthMethod userAuthMethod
|
||||
UserInfoField userInfoField
|
||||
UserRemoteLinks userRemoteLinks
|
||||
UserToBeing userToBeing
|
||||
UserToRole userToRole
|
||||
UserToTag userToTag
|
||||
UserToUserRelation userToUserRelation
|
||||
}
|
||||
|
||||
func (q *Query) Available() bool { return q.db != nil }
|
||||
|
||||
func (q *Query) clone(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Emote: q.Emote.clone(db),
|
||||
MediaMetadata: q.MediaMetadata.clone(db),
|
||||
Note: q.Note.clone(db),
|
||||
NoteTag: q.NoteTag.clone(db),
|
||||
NoteToAttachment: q.NoteToAttachment.clone(db),
|
||||
NoteToEmote: q.NoteToEmote.clone(db),
|
||||
NoteToPing: q.NoteToPing.clone(db),
|
||||
Reaction: q.Reaction.clone(db),
|
||||
RemoteServer: q.RemoteServer.clone(db),
|
||||
Role: q.Role.clone(db),
|
||||
User: q.User.clone(db),
|
||||
UserAuthMethod: q.UserAuthMethod.clone(db),
|
||||
UserInfoField: q.UserInfoField.clone(db),
|
||||
UserRemoteLinks: q.UserRemoteLinks.clone(db),
|
||||
UserToBeing: q.UserToBeing.clone(db),
|
||||
UserToRole: q.UserToRole.clone(db),
|
||||
UserToTag: q.UserToTag.clone(db),
|
||||
UserToUserRelation: q.UserToUserRelation.clone(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (q *Query) ReadDB() *Query {
|
||||
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
|
||||
}
|
||||
|
||||
func (q *Query) WriteDB() *Query {
|
||||
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
|
||||
}
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Emote: q.Emote.replaceDB(db),
|
||||
MediaMetadata: q.MediaMetadata.replaceDB(db),
|
||||
Note: q.Note.replaceDB(db),
|
||||
NoteTag: q.NoteTag.replaceDB(db),
|
||||
NoteToAttachment: q.NoteToAttachment.replaceDB(db),
|
||||
NoteToEmote: q.NoteToEmote.replaceDB(db),
|
||||
NoteToPing: q.NoteToPing.replaceDB(db),
|
||||
Reaction: q.Reaction.replaceDB(db),
|
||||
RemoteServer: q.RemoteServer.replaceDB(db),
|
||||
Role: q.Role.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
UserAuthMethod: q.UserAuthMethod.replaceDB(db),
|
||||
UserInfoField: q.UserInfoField.replaceDB(db),
|
||||
UserRemoteLinks: q.UserRemoteLinks.replaceDB(db),
|
||||
UserToBeing: q.UserToBeing.replaceDB(db),
|
||||
UserToRole: q.UserToRole.replaceDB(db),
|
||||
UserToTag: q.UserToTag.replaceDB(db),
|
||||
UserToUserRelation: q.UserToUserRelation.replaceDB(db),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
Emote IEmoteDo
|
||||
MediaMetadata IMediaMetadataDo
|
||||
Note INoteDo
|
||||
NoteTag INoteTagDo
|
||||
NoteToAttachment INoteToAttachmentDo
|
||||
NoteToEmote INoteToEmoteDo
|
||||
NoteToPing INoteToPingDo
|
||||
Reaction IReactionDo
|
||||
RemoteServer IRemoteServerDo
|
||||
Role IRoleDo
|
||||
User IUserDo
|
||||
UserAuthMethod IUserAuthMethodDo
|
||||
UserInfoField IUserInfoFieldDo
|
||||
UserRemoteLinks IUserRemoteLinksDo
|
||||
UserToBeing IUserToBeingDo
|
||||
UserToRole IUserToRoleDo
|
||||
UserToTag IUserToTagDo
|
||||
UserToUserRelation IUserToUserRelationDo
|
||||
}
|
||||
|
||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
return &queryCtx{
|
||||
Emote: q.Emote.WithContext(ctx),
|
||||
MediaMetadata: q.MediaMetadata.WithContext(ctx),
|
||||
Note: q.Note.WithContext(ctx),
|
||||
NoteTag: q.NoteTag.WithContext(ctx),
|
||||
NoteToAttachment: q.NoteToAttachment.WithContext(ctx),
|
||||
NoteToEmote: q.NoteToEmote.WithContext(ctx),
|
||||
NoteToPing: q.NoteToPing.WithContext(ctx),
|
||||
Reaction: q.Reaction.WithContext(ctx),
|
||||
RemoteServer: q.RemoteServer.WithContext(ctx),
|
||||
Role: q.Role.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
UserAuthMethod: q.UserAuthMethod.WithContext(ctx),
|
||||
UserInfoField: q.UserInfoField.WithContext(ctx),
|
||||
UserRemoteLinks: q.UserRemoteLinks.WithContext(ctx),
|
||||
UserToBeing: q.UserToBeing.WithContext(ctx),
|
||||
UserToRole: q.UserToRole.WithContext(ctx),
|
||||
UserToTag: q.UserToTag.WithContext(ctx),
|
||||
UserToUserRelation: q.UserToUserRelation.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
|
||||
return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
|
||||
}
|
||||
|
||||
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
|
||||
tx := q.db.Begin(opts...)
|
||||
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
|
||||
}
|
||||
|
||||
type QueryTx struct {
|
||||
*Query
|
||||
Error error
|
||||
}
|
||||
|
||||
func (q *QueryTx) Commit() error {
|
||||
return q.db.Commit().Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) Rollback() error {
|
||||
return q.db.Rollback().Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) SavePoint(name string) error {
|
||||
return q.db.SavePoint(name).Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) RollbackTo(name string) error {
|
||||
return q.db.RollbackTo(name).Error
|
||||
}
|
419
storage-new/dbgen/media_metadata.gen.go
Normal file
419
storage-new/dbgen/media_metadata.gen.go
Normal file
|
@ -0,0 +1,419 @@
|
|||
// 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 newMediaMetadata(db *gorm.DB, opts ...gen.DOOption) mediaMetadata {
|
||||
_mediaMetadata := mediaMetadata{}
|
||||
|
||||
_mediaMetadata.mediaMetadataDo.UseDB(db, opts...)
|
||||
_mediaMetadata.mediaMetadataDo.UseModel(&models.MediaMetadata{})
|
||||
|
||||
tableName := _mediaMetadata.mediaMetadataDo.TableName()
|
||||
_mediaMetadata.ALL = field.NewAsterisk(tableName)
|
||||
_mediaMetadata.ID = field.NewString(tableName, "id")
|
||||
_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.Remote = field.NewBool(tableName, "remote")
|
||||
_mediaMetadata.Location = field.NewString(tableName, "location")
|
||||
_mediaMetadata.Type = field.NewString(tableName, "type")
|
||||
_mediaMetadata.Name = field.NewString(tableName, "name")
|
||||
_mediaMetadata.AltText = field.NewString(tableName, "alt_text")
|
||||
_mediaMetadata.Blurred = field.NewBool(tableName, "blurred")
|
||||
|
||||
_mediaMetadata.fillFieldMap()
|
||||
|
||||
return _mediaMetadata
|
||||
}
|
||||
|
||||
type mediaMetadata struct {
|
||||
mediaMetadataDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
OwnedBy field.String
|
||||
Remote field.Bool
|
||||
Location field.String
|
||||
Type field.String
|
||||
Name field.String
|
||||
AltText field.String
|
||||
Blurred field.Bool
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (m mediaMetadata) Table(newTableName string) *mediaMetadata {
|
||||
m.mediaMetadataDo.UseTable(newTableName)
|
||||
return m.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (m mediaMetadata) As(alias string) *mediaMetadata {
|
||||
m.mediaMetadataDo.DO = *(m.mediaMetadataDo.As(alias).(*gen.DO))
|
||||
return m.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (m *mediaMetadata) updateTableName(table string) *mediaMetadata {
|
||||
m.ALL = field.NewAsterisk(table)
|
||||
m.ID = field.NewString(table, "id")
|
||||
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.Remote = field.NewBool(table, "remote")
|
||||
m.Location = field.NewString(table, "location")
|
||||
m.Type = field.NewString(table, "type")
|
||||
m.Name = field.NewString(table, "name")
|
||||
m.AltText = field.NewString(table, "alt_text")
|
||||
m.Blurred = field.NewBool(table, "blurred")
|
||||
|
||||
m.fillFieldMap()
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *mediaMetadata) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := m.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (m *mediaMetadata) fillFieldMap() {
|
||||
m.fieldMap = make(map[string]field.Expr, 11)
|
||||
m.fieldMap["id"] = m.ID
|
||||
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["remote"] = m.Remote
|
||||
m.fieldMap["location"] = m.Location
|
||||
m.fieldMap["type"] = m.Type
|
||||
m.fieldMap["name"] = m.Name
|
||||
m.fieldMap["alt_text"] = m.AltText
|
||||
m.fieldMap["blurred"] = m.Blurred
|
||||
}
|
||||
|
||||
func (m mediaMetadata) clone(db *gorm.DB) mediaMetadata {
|
||||
m.mediaMetadataDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return m
|
||||
}
|
||||
|
||||
func (m mediaMetadata) replaceDB(db *gorm.DB) mediaMetadata {
|
||||
m.mediaMetadataDo.ReplaceDB(db)
|
||||
return m
|
||||
}
|
||||
|
||||
type mediaMetadataDo struct{ gen.DO }
|
||||
|
||||
type IMediaMetadataDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IMediaMetadataDo
|
||||
WithContext(ctx context.Context) IMediaMetadataDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IMediaMetadataDo
|
||||
WriteDB() IMediaMetadataDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IMediaMetadataDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IMediaMetadataDo
|
||||
Not(conds ...gen.Condition) IMediaMetadataDo
|
||||
Or(conds ...gen.Condition) IMediaMetadataDo
|
||||
Select(conds ...field.Expr) IMediaMetadataDo
|
||||
Where(conds ...gen.Condition) IMediaMetadataDo
|
||||
Order(conds ...field.Expr) IMediaMetadataDo
|
||||
Distinct(cols ...field.Expr) IMediaMetadataDo
|
||||
Omit(cols ...field.Expr) IMediaMetadataDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IMediaMetadataDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IMediaMetadataDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IMediaMetadataDo
|
||||
Group(cols ...field.Expr) IMediaMetadataDo
|
||||
Having(conds ...gen.Condition) IMediaMetadataDo
|
||||
Limit(limit int) IMediaMetadataDo
|
||||
Offset(offset int) IMediaMetadataDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IMediaMetadataDo
|
||||
Unscoped() IMediaMetadataDo
|
||||
Create(values ...*models.MediaMetadata) error
|
||||
CreateInBatches(values []*models.MediaMetadata, batchSize int) error
|
||||
Save(values ...*models.MediaMetadata) error
|
||||
First() (*models.MediaMetadata, error)
|
||||
Take() (*models.MediaMetadata, error)
|
||||
Last() (*models.MediaMetadata, error)
|
||||
Find() ([]*models.MediaMetadata, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.MediaMetadata, err error)
|
||||
FindInBatches(result *[]*models.MediaMetadata, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.MediaMetadata) (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) IMediaMetadataDo
|
||||
Assign(attrs ...field.AssignExpr) IMediaMetadataDo
|
||||
Joins(fields ...field.RelationField) IMediaMetadataDo
|
||||
Preload(fields ...field.RelationField) IMediaMetadataDo
|
||||
FirstOrInit() (*models.MediaMetadata, error)
|
||||
FirstOrCreate() (*models.MediaMetadata, error)
|
||||
FindByPage(offset int, limit int) (result []*models.MediaMetadata, 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) IMediaMetadataDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Debug() IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Debug())
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) WithContext(ctx context.Context) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) ReadDB() IMediaMetadataDo {
|
||||
return m.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) WriteDB() IMediaMetadataDo {
|
||||
return m.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Session(config *gorm.Session) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Session(config))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Clauses(conds ...clause.Expression) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Returning(value interface{}, columns ...string) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Not(conds ...gen.Condition) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Or(conds ...gen.Condition) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Select(conds ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Where(conds ...gen.Condition) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Order(conds ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Distinct(cols ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Omit(cols ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Join(table schema.Tabler, on ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) LeftJoin(table schema.Tabler, on ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) RightJoin(table schema.Tabler, on ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Group(cols ...field.Expr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Having(conds ...gen.Condition) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Limit(limit int) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Offset(offset int) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Unscoped() IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Create(values ...*models.MediaMetadata) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return m.DO.Create(values)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) CreateInBatches(values []*models.MediaMetadata, batchSize int) error {
|
||||
return m.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 (m mediaMetadataDo) Save(values ...*models.MediaMetadata) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return m.DO.Save(values)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) First() (*models.MediaMetadata, error) {
|
||||
if result, err := m.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.MediaMetadata), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Take() (*models.MediaMetadata, error) {
|
||||
if result, err := m.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.MediaMetadata), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Last() (*models.MediaMetadata, error) {
|
||||
if result, err := m.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.MediaMetadata), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Find() ([]*models.MediaMetadata, error) {
|
||||
result, err := m.DO.Find()
|
||||
return result.([]*models.MediaMetadata), err
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.MediaMetadata, err error) {
|
||||
buf := make([]*models.MediaMetadata, 0, batchSize)
|
||||
err = m.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 (m mediaMetadataDo) FindInBatches(result *[]*models.MediaMetadata, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return m.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Attrs(attrs ...field.AssignExpr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Assign(attrs ...field.AssignExpr) IMediaMetadataDo {
|
||||
return m.withDO(m.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Joins(fields ...field.RelationField) IMediaMetadataDo {
|
||||
for _, _f := range fields {
|
||||
m = *m.withDO(m.DO.Joins(_f))
|
||||
}
|
||||
return &m
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Preload(fields ...field.RelationField) IMediaMetadataDo {
|
||||
for _, _f := range fields {
|
||||
m = *m.withDO(m.DO.Preload(_f))
|
||||
}
|
||||
return &m
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) FirstOrInit() (*models.MediaMetadata, error) {
|
||||
if result, err := m.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.MediaMetadata), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) FirstOrCreate() (*models.MediaMetadata, error) {
|
||||
if result, err := m.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.MediaMetadata), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) FindByPage(offset int, limit int) (result []*models.MediaMetadata, count int64, err error) {
|
||||
result, err = m.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 = m.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = m.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = m.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Scan(result interface{}) (err error) {
|
||||
return m.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (m mediaMetadataDo) Delete(models ...*models.MediaMetadata) (result gen.ResultInfo, err error) {
|
||||
return m.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (m *mediaMetadataDo) withDO(do gen.Dao) *mediaMetadataDo {
|
||||
m.DO = *do.(*gen.DO)
|
||||
return m
|
||||
}
|
599
storage-new/dbgen/note_tags.gen.go
Normal file
599
storage-new/dbgen/note_tags.gen.go
Normal file
|
@ -0,0 +1,599 @@
|
|||
// 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 newNoteTag(db *gorm.DB, opts ...gen.DOOption) noteTag {
|
||||
_noteTag := noteTag{}
|
||||
|
||||
_noteTag.noteTagDo.UseDB(db, opts...)
|
||||
_noteTag.noteTagDo.UseModel(&models.NoteTag{})
|
||||
|
||||
tableName := _noteTag.noteTagDo.TableName()
|
||||
_noteTag.ALL = field.NewAsterisk(tableName)
|
||||
_noteTag.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteTag.Tag = field.NewString(tableName, "tag")
|
||||
_noteTag.Note = noteTagBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
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
|
||||
}
|
||||
}
|
||||
}{
|
||||
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
|
||||
}
|
||||
}{
|
||||
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
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteTag.fillFieldMap()
|
||||
|
||||
return _noteTag
|
||||
}
|
||||
|
||||
type noteTag struct {
|
||||
noteTagDo
|
||||
|
||||
ALL field.Asterisk
|
||||
NoteId field.String
|
||||
Tag field.String
|
||||
Note noteTagBelongsToNote
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteTag) Table(newTableName string) *noteTag {
|
||||
n.noteTagDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteTag) As(alias string) *noteTag {
|
||||
n.noteTagDo.DO = *(n.noteTagDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteTag) updateTableName(table string) *noteTag {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
n.Tag = field.NewString(table, "tag")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteTag) 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 *noteTag) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 3)
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
n.fieldMap["tag"] = n.Tag
|
||||
|
||||
}
|
||||
|
||||
func (n noteTag) clone(db *gorm.DB) noteTag {
|
||||
n.noteTagDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteTag) replaceDB(db *gorm.DB) noteTag {
|
||||
n.noteTagDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteTagBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteTagBelongsToNote) Where(conds ...field.Expr) *noteTagBelongsToNote {
|
||||
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 noteTagBelongsToNote) WithContext(ctx context.Context) *noteTagBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteTagBelongsToNote) Session(session *gorm.Session) *noteTagBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteTagBelongsToNote) Model(m *models.NoteTag) *noteTagBelongsToNoteTx {
|
||||
return ¬eTagBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteTagBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteTagBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteTagBelongsToNoteTx) 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 noteTagBelongsToNoteTx) 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 noteTagBelongsToNoteTx) 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 noteTagBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteTagBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteTagDo struct{ gen.DO }
|
||||
|
||||
type INoteTagDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteTagDo
|
||||
WithContext(ctx context.Context) INoteTagDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteTagDo
|
||||
WriteDB() INoteTagDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteTagDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteTagDo
|
||||
Not(conds ...gen.Condition) INoteTagDo
|
||||
Or(conds ...gen.Condition) INoteTagDo
|
||||
Select(conds ...field.Expr) INoteTagDo
|
||||
Where(conds ...gen.Condition) INoteTagDo
|
||||
Order(conds ...field.Expr) INoteTagDo
|
||||
Distinct(cols ...field.Expr) INoteTagDo
|
||||
Omit(cols ...field.Expr) INoteTagDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteTagDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteTagDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteTagDo
|
||||
Group(cols ...field.Expr) INoteTagDo
|
||||
Having(conds ...gen.Condition) INoteTagDo
|
||||
Limit(limit int) INoteTagDo
|
||||
Offset(offset int) INoteTagDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteTagDo
|
||||
Unscoped() INoteTagDo
|
||||
Create(values ...*models.NoteTag) error
|
||||
CreateInBatches(values []*models.NoteTag, batchSize int) error
|
||||
Save(values ...*models.NoteTag) error
|
||||
First() (*models.NoteTag, error)
|
||||
Take() (*models.NoteTag, error)
|
||||
Last() (*models.NoteTag, error)
|
||||
Find() ([]*models.NoteTag, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteTag, err error)
|
||||
FindInBatches(result *[]*models.NoteTag, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteTag) (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) INoteTagDo
|
||||
Assign(attrs ...field.AssignExpr) INoteTagDo
|
||||
Joins(fields ...field.RelationField) INoteTagDo
|
||||
Preload(fields ...field.RelationField) INoteTagDo
|
||||
FirstOrInit() (*models.NoteTag, error)
|
||||
FirstOrCreate() (*models.NoteTag, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteTag, 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) INoteTagDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteTagDo) Debug() INoteTagDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteTagDo) WithContext(ctx context.Context) INoteTagDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteTagDo) ReadDB() INoteTagDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteTagDo) WriteDB() INoteTagDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteTagDo) Session(config *gorm.Session) INoteTagDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Clauses(conds ...clause.Expression) INoteTagDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Returning(value interface{}, columns ...string) INoteTagDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Not(conds ...gen.Condition) INoteTagDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Or(conds ...gen.Condition) INoteTagDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Select(conds ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Where(conds ...gen.Condition) INoteTagDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Order(conds ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Distinct(cols ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Omit(cols ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Join(table schema.Tabler, on ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Group(cols ...field.Expr) INoteTagDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Having(conds ...gen.Condition) INoteTagDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Limit(limit int) INoteTagDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Offset(offset int) INoteTagDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteTagDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Unscoped() INoteTagDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteTagDo) Create(values ...*models.NoteTag) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteTagDo) CreateInBatches(values []*models.NoteTag, 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 noteTagDo) Save(values ...*models.NoteTag) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteTagDo) First() (*models.NoteTag, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteTagDo) Take() (*models.NoteTag, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteTagDo) Last() (*models.NoteTag, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteTagDo) Find() ([]*models.NoteTag, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteTag), err
|
||||
}
|
||||
|
||||
func (n noteTagDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteTag, err error) {
|
||||
buf := make([]*models.NoteTag, 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 noteTagDo) FindInBatches(result *[]*models.NoteTag, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteTagDo) Attrs(attrs ...field.AssignExpr) INoteTagDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Assign(attrs ...field.AssignExpr) INoteTagDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteTagDo) Joins(fields ...field.RelationField) INoteTagDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteTagDo) Preload(fields ...field.RelationField) INoteTagDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteTagDo) FirstOrInit() (*models.NoteTag, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteTagDo) FirstOrCreate() (*models.NoteTag, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteTagDo) FindByPage(offset int, limit int) (result []*models.NoteTag, 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 noteTagDo) 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 noteTagDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteTagDo) Delete(models ...*models.NoteTag) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteTagDo) withDO(do gen.Dao) *noteTagDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
678
storage-new/dbgen/note_to_attachments.gen.go
Normal file
678
storage-new/dbgen/note_to_attachments.gen.go
Normal file
|
@ -0,0 +1,678 @@
|
|||
// 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 newNoteToAttachment(db *gorm.DB, opts ...gen.DOOption) noteToAttachment {
|
||||
_noteToAttachment := noteToAttachment{}
|
||||
|
||||
_noteToAttachment.noteToAttachmentDo.UseDB(db, opts...)
|
||||
_noteToAttachment.noteToAttachmentDo.UseModel(&models.NoteToAttachment{})
|
||||
|
||||
tableName := _noteToAttachment.noteToAttachmentDo.TableName()
|
||||
_noteToAttachment.ALL = field.NewAsterisk(tableName)
|
||||
_noteToAttachment.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToAttachment.AttachmentId = field.NewString(tableName, "attachment_id")
|
||||
_noteToAttachment.Note = noteToAttachmentBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
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
|
||||
}
|
||||
}
|
||||
}{
|
||||
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
|
||||
}
|
||||
}{
|
||||
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
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToAttachment.Attachment = noteToAttachmentBelongsToAttachment{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Attachment", "models.MediaMetadata"),
|
||||
}
|
||||
|
||||
_noteToAttachment.fillFieldMap()
|
||||
|
||||
return _noteToAttachment
|
||||
}
|
||||
|
||||
type noteToAttachment struct {
|
||||
noteToAttachmentDo
|
||||
|
||||
ALL field.Asterisk
|
||||
NoteId field.String
|
||||
AttachmentId field.String
|
||||
Note noteToAttachmentBelongsToNote
|
||||
|
||||
Attachment noteToAttachmentBelongsToAttachment
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteToAttachment) Table(newTableName string) *noteToAttachment {
|
||||
n.noteToAttachmentDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteToAttachment) As(alias string) *noteToAttachment {
|
||||
n.noteToAttachmentDo.DO = *(n.noteToAttachmentDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteToAttachment) updateTableName(table string) *noteToAttachment {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
n.AttachmentId = field.NewString(table, "attachment_id")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteToAttachment) 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 *noteToAttachment) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 4)
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
n.fieldMap["attachment_id"] = n.AttachmentId
|
||||
|
||||
}
|
||||
|
||||
func (n noteToAttachment) clone(db *gorm.DB) noteToAttachment {
|
||||
n.noteToAttachmentDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToAttachment) replaceDB(db *gorm.DB) noteToAttachment {
|
||||
n.noteToAttachmentDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteToAttachmentBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToNote) Where(conds ...field.Expr) *noteToAttachmentBelongsToNote {
|
||||
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 noteToAttachmentBelongsToNote) WithContext(ctx context.Context) *noteToAttachmentBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToNote) Session(session *gorm.Session) *noteToAttachmentBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToNote) Model(m *models.NoteToAttachment) *noteToAttachmentBelongsToNoteTx {
|
||||
return ¬eToAttachmentBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToAttachmentBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToAttachmentBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToNoteTx) 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 noteToAttachmentBelongsToNoteTx) 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 noteToAttachmentBelongsToNoteTx) 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 noteToAttachmentBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToAttachmentBelongsToAttachment struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachment) Where(conds ...field.Expr) *noteToAttachmentBelongsToAttachment {
|
||||
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 noteToAttachmentBelongsToAttachment) WithContext(ctx context.Context) *noteToAttachmentBelongsToAttachment {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachment) Session(session *gorm.Session) *noteToAttachmentBelongsToAttachment {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachment) Model(m *models.NoteToAttachment) *noteToAttachmentBelongsToAttachmentTx {
|
||||
return ¬eToAttachmentBelongsToAttachmentTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToAttachmentBelongsToAttachmentTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Find() (result *models.MediaMetadata, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Append(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Replace(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Delete(values ...*models.MediaMetadata) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToAttachmentBelongsToAttachmentTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToAttachmentDo struct{ gen.DO }
|
||||
|
||||
type INoteToAttachmentDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteToAttachmentDo
|
||||
WithContext(ctx context.Context) INoteToAttachmentDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteToAttachmentDo
|
||||
WriteDB() INoteToAttachmentDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteToAttachmentDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteToAttachmentDo
|
||||
Not(conds ...gen.Condition) INoteToAttachmentDo
|
||||
Or(conds ...gen.Condition) INoteToAttachmentDo
|
||||
Select(conds ...field.Expr) INoteToAttachmentDo
|
||||
Where(conds ...gen.Condition) INoteToAttachmentDo
|
||||
Order(conds ...field.Expr) INoteToAttachmentDo
|
||||
Distinct(cols ...field.Expr) INoteToAttachmentDo
|
||||
Omit(cols ...field.Expr) INoteToAttachmentDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo
|
||||
Group(cols ...field.Expr) INoteToAttachmentDo
|
||||
Having(conds ...gen.Condition) INoteToAttachmentDo
|
||||
Limit(limit int) INoteToAttachmentDo
|
||||
Offset(offset int) INoteToAttachmentDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToAttachmentDo
|
||||
Unscoped() INoteToAttachmentDo
|
||||
Create(values ...*models.NoteToAttachment) error
|
||||
CreateInBatches(values []*models.NoteToAttachment, batchSize int) error
|
||||
Save(values ...*models.NoteToAttachment) error
|
||||
First() (*models.NoteToAttachment, error)
|
||||
Take() (*models.NoteToAttachment, error)
|
||||
Last() (*models.NoteToAttachment, error)
|
||||
Find() ([]*models.NoteToAttachment, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToAttachment, err error)
|
||||
FindInBatches(result *[]*models.NoteToAttachment, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteToAttachment) (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) INoteToAttachmentDo
|
||||
Assign(attrs ...field.AssignExpr) INoteToAttachmentDo
|
||||
Joins(fields ...field.RelationField) INoteToAttachmentDo
|
||||
Preload(fields ...field.RelationField) INoteToAttachmentDo
|
||||
FirstOrInit() (*models.NoteToAttachment, error)
|
||||
FirstOrCreate() (*models.NoteToAttachment, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToAttachment, 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) INoteToAttachmentDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Debug() INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) WithContext(ctx context.Context) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) ReadDB() INoteToAttachmentDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) WriteDB() INoteToAttachmentDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Session(config *gorm.Session) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Clauses(conds ...clause.Expression) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Returning(value interface{}, columns ...string) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Not(conds ...gen.Condition) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Or(conds ...gen.Condition) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Select(conds ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Where(conds ...gen.Condition) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Order(conds ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Distinct(cols ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Omit(cols ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Join(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Group(cols ...field.Expr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Having(conds ...gen.Condition) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Limit(limit int) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Offset(offset int) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Unscoped() INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Create(values ...*models.NoteToAttachment) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) CreateInBatches(values []*models.NoteToAttachment, 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 noteToAttachmentDo) Save(values ...*models.NoteToAttachment) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) First() (*models.NoteToAttachment, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToAttachment), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Take() (*models.NoteToAttachment, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToAttachment), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Last() (*models.NoteToAttachment, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToAttachment), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Find() ([]*models.NoteToAttachment, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteToAttachment), err
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToAttachment, err error) {
|
||||
buf := make([]*models.NoteToAttachment, 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 noteToAttachmentDo) FindInBatches(result *[]*models.NoteToAttachment, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Attrs(attrs ...field.AssignExpr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Assign(attrs ...field.AssignExpr) INoteToAttachmentDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Joins(fields ...field.RelationField) INoteToAttachmentDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Preload(fields ...field.RelationField) INoteToAttachmentDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) FirstOrInit() (*models.NoteToAttachment, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToAttachment), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) FirstOrCreate() (*models.NoteToAttachment, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToAttachment), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) FindByPage(offset int, limit int) (result []*models.NoteToAttachment, 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 noteToAttachmentDo) 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 noteToAttachmentDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteToAttachmentDo) Delete(models ...*models.NoteToAttachment) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteToAttachmentDo) withDO(do gen.Dao) *noteToAttachmentDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
678
storage-new/dbgen/note_to_emotes.gen.go
Normal file
678
storage-new/dbgen/note_to_emotes.gen.go
Normal file
|
@ -0,0 +1,678 @@
|
|||
// 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 newNoteToEmote(db *gorm.DB, opts ...gen.DOOption) noteToEmote {
|
||||
_noteToEmote := noteToEmote{}
|
||||
|
||||
_noteToEmote.noteToEmoteDo.UseDB(db, opts...)
|
||||
_noteToEmote.noteToEmoteDo.UseModel(&models.NoteToEmote{})
|
||||
|
||||
tableName := _noteToEmote.noteToEmoteDo.TableName()
|
||||
_noteToEmote.ALL = field.NewAsterisk(tableName)
|
||||
_noteToEmote.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToEmote.EmoteId = field.NewString(tableName, "emote_id")
|
||||
_noteToEmote.Note = noteToEmoteBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
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
|
||||
}
|
||||
}
|
||||
}{
|
||||
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
|
||||
}
|
||||
}{
|
||||
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
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToEmote.Emote = noteToEmoteBelongsToEmote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Emote", "models.Emote"),
|
||||
}
|
||||
|
||||
_noteToEmote.fillFieldMap()
|
||||
|
||||
return _noteToEmote
|
||||
}
|
||||
|
||||
type noteToEmote struct {
|
||||
noteToEmoteDo
|
||||
|
||||
ALL field.Asterisk
|
||||
NoteId field.String
|
||||
EmoteId field.String
|
||||
Note noteToEmoteBelongsToNote
|
||||
|
||||
Emote noteToEmoteBelongsToEmote
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteToEmote) Table(newTableName string) *noteToEmote {
|
||||
n.noteToEmoteDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteToEmote) As(alias string) *noteToEmote {
|
||||
n.noteToEmoteDo.DO = *(n.noteToEmoteDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteToEmote) updateTableName(table string) *noteToEmote {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
n.EmoteId = field.NewString(table, "emote_id")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteToEmote) 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 *noteToEmote) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 4)
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
n.fieldMap["emote_id"] = n.EmoteId
|
||||
|
||||
}
|
||||
|
||||
func (n noteToEmote) clone(db *gorm.DB) noteToEmote {
|
||||
n.noteToEmoteDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToEmote) replaceDB(db *gorm.DB) noteToEmote {
|
||||
n.noteToEmoteDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteToEmoteBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToNote) Where(conds ...field.Expr) *noteToEmoteBelongsToNote {
|
||||
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 noteToEmoteBelongsToNote) WithContext(ctx context.Context) *noteToEmoteBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToNote) Session(session *gorm.Session) *noteToEmoteBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToNote) Model(m *models.NoteToEmote) *noteToEmoteBelongsToNoteTx {
|
||||
return ¬eToEmoteBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToEmoteBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToEmoteBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToNoteTx) 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 noteToEmoteBelongsToNoteTx) 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 noteToEmoteBelongsToNoteTx) 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 noteToEmoteBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToEmoteBelongsToEmote struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmote) Where(conds ...field.Expr) *noteToEmoteBelongsToEmote {
|
||||
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 noteToEmoteBelongsToEmote) WithContext(ctx context.Context) *noteToEmoteBelongsToEmote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmote) Session(session *gorm.Session) *noteToEmoteBelongsToEmote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmote) Model(m *models.NoteToEmote) *noteToEmoteBelongsToEmoteTx {
|
||||
return ¬eToEmoteBelongsToEmoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToEmoteBelongsToEmoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Find() (result *models.Emote, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Append(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Replace(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Delete(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToEmoteBelongsToEmoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToEmoteDo struct{ gen.DO }
|
||||
|
||||
type INoteToEmoteDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteToEmoteDo
|
||||
WithContext(ctx context.Context) INoteToEmoteDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteToEmoteDo
|
||||
WriteDB() INoteToEmoteDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteToEmoteDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteToEmoteDo
|
||||
Not(conds ...gen.Condition) INoteToEmoteDo
|
||||
Or(conds ...gen.Condition) INoteToEmoteDo
|
||||
Select(conds ...field.Expr) INoteToEmoteDo
|
||||
Where(conds ...gen.Condition) INoteToEmoteDo
|
||||
Order(conds ...field.Expr) INoteToEmoteDo
|
||||
Distinct(cols ...field.Expr) INoteToEmoteDo
|
||||
Omit(cols ...field.Expr) INoteToEmoteDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteToEmoteDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteToEmoteDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteToEmoteDo
|
||||
Group(cols ...field.Expr) INoteToEmoteDo
|
||||
Having(conds ...gen.Condition) INoteToEmoteDo
|
||||
Limit(limit int) INoteToEmoteDo
|
||||
Offset(offset int) INoteToEmoteDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToEmoteDo
|
||||
Unscoped() INoteToEmoteDo
|
||||
Create(values ...*models.NoteToEmote) error
|
||||
CreateInBatches(values []*models.NoteToEmote, batchSize int) error
|
||||
Save(values ...*models.NoteToEmote) error
|
||||
First() (*models.NoteToEmote, error)
|
||||
Take() (*models.NoteToEmote, error)
|
||||
Last() (*models.NoteToEmote, error)
|
||||
Find() ([]*models.NoteToEmote, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToEmote, err error)
|
||||
FindInBatches(result *[]*models.NoteToEmote, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteToEmote) (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) INoteToEmoteDo
|
||||
Assign(attrs ...field.AssignExpr) INoteToEmoteDo
|
||||
Joins(fields ...field.RelationField) INoteToEmoteDo
|
||||
Preload(fields ...field.RelationField) INoteToEmoteDo
|
||||
FirstOrInit() (*models.NoteToEmote, error)
|
||||
FirstOrCreate() (*models.NoteToEmote, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToEmote, 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) INoteToEmoteDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Debug() INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) WithContext(ctx context.Context) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) ReadDB() INoteToEmoteDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) WriteDB() INoteToEmoteDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Session(config *gorm.Session) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Clauses(conds ...clause.Expression) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Returning(value interface{}, columns ...string) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Not(conds ...gen.Condition) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Or(conds ...gen.Condition) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Select(conds ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Where(conds ...gen.Condition) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Order(conds ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Distinct(cols ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Omit(cols ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Join(table schema.Tabler, on ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Group(cols ...field.Expr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Having(conds ...gen.Condition) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Limit(limit int) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Offset(offset int) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Unscoped() INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Create(values ...*models.NoteToEmote) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) CreateInBatches(values []*models.NoteToEmote, 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 noteToEmoteDo) Save(values ...*models.NoteToEmote) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) First() (*models.NoteToEmote, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToEmote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Take() (*models.NoteToEmote, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToEmote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Last() (*models.NoteToEmote, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToEmote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Find() ([]*models.NoteToEmote, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteToEmote), err
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToEmote, err error) {
|
||||
buf := make([]*models.NoteToEmote, 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 noteToEmoteDo) FindInBatches(result *[]*models.NoteToEmote, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Attrs(attrs ...field.AssignExpr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Assign(attrs ...field.AssignExpr) INoteToEmoteDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Joins(fields ...field.RelationField) INoteToEmoteDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Preload(fields ...field.RelationField) INoteToEmoteDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) FirstOrInit() (*models.NoteToEmote, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToEmote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) FirstOrCreate() (*models.NoteToEmote, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToEmote), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) FindByPage(offset int, limit int) (result []*models.NoteToEmote, 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 noteToEmoteDo) 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 noteToEmoteDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteToEmoteDo) Delete(models ...*models.NoteToEmote) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteToEmoteDo) withDO(do gen.Dao) *noteToEmoteDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
678
storage-new/dbgen/note_to_pings.gen.go
Normal file
678
storage-new/dbgen/note_to_pings.gen.go
Normal file
|
@ -0,0 +1,678 @@
|
|||
// 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 newNoteToPing(db *gorm.DB, opts ...gen.DOOption) noteToPing {
|
||||
_noteToPing := noteToPing{}
|
||||
|
||||
_noteToPing.noteToPingDo.UseDB(db, opts...)
|
||||
_noteToPing.noteToPingDo.UseModel(&models.NoteToPing{})
|
||||
|
||||
tableName := _noteToPing.noteToPingDo.TableName()
|
||||
_noteToPing.ALL = field.NewAsterisk(tableName)
|
||||
_noteToPing.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToPing.PingTargetId = field.NewString(tableName, "ping_target_id")
|
||||
_noteToPing.Note = noteToPingBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
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
|
||||
}
|
||||
}
|
||||
}{
|
||||
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
|
||||
}
|
||||
}{
|
||||
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
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_noteToPing.PingTarget = noteToPingBelongsToPingTarget{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("PingTarget", "models.User"),
|
||||
}
|
||||
|
||||
_noteToPing.fillFieldMap()
|
||||
|
||||
return _noteToPing
|
||||
}
|
||||
|
||||
type noteToPing struct {
|
||||
noteToPingDo
|
||||
|
||||
ALL field.Asterisk
|
||||
NoteId field.String
|
||||
PingTargetId field.String
|
||||
Note noteToPingBelongsToNote
|
||||
|
||||
PingTarget noteToPingBelongsToPingTarget
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n noteToPing) Table(newTableName string) *noteToPing {
|
||||
n.noteToPingDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n noteToPing) As(alias string) *noteToPing {
|
||||
n.noteToPingDo.DO = *(n.noteToPingDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *noteToPing) updateTableName(table string) *noteToPing {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
n.PingTargetId = field.NewString(table, "ping_target_id")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *noteToPing) 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 *noteToPing) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 4)
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
n.fieldMap["ping_target_id"] = n.PingTargetId
|
||||
|
||||
}
|
||||
|
||||
func (n noteToPing) clone(db *gorm.DB) noteToPing {
|
||||
n.noteToPingDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToPing) replaceDB(db *gorm.DB) noteToPing {
|
||||
n.noteToPingDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteToPingBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToNote) Where(conds ...field.Expr) *noteToPingBelongsToNote {
|
||||
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 noteToPingBelongsToNote) WithContext(ctx context.Context) *noteToPingBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToNote) Session(session *gorm.Session) *noteToPingBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToNote) Model(m *models.NoteToPing) *noteToPingBelongsToNoteTx {
|
||||
return ¬eToPingBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToPingBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToPingBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToNoteTx) 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 noteToPingBelongsToNoteTx) 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 noteToPingBelongsToNoteTx) 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 noteToPingBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToPingBelongsToPingTarget struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToPingTarget) Where(conds ...field.Expr) *noteToPingBelongsToPingTarget {
|
||||
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 noteToPingBelongsToPingTarget) WithContext(ctx context.Context) *noteToPingBelongsToPingTarget {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToPingTarget) Session(session *gorm.Session) *noteToPingBelongsToPingTarget {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToPingTarget) Model(m *models.NoteToPing) *noteToPingBelongsToPingTargetTx {
|
||||
return ¬eToPingBelongsToPingTargetTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteToPingBelongsToPingTargetTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToPingBelongsToPingTargetTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToPingTargetTx) 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 noteToPingBelongsToPingTargetTx) 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 noteToPingBelongsToPingTargetTx) 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 noteToPingBelongsToPingTargetTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToPingBelongsToPingTargetTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteToPingDo struct{ gen.DO }
|
||||
|
||||
type INoteToPingDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteToPingDo
|
||||
WithContext(ctx context.Context) INoteToPingDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteToPingDo
|
||||
WriteDB() INoteToPingDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteToPingDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteToPingDo
|
||||
Not(conds ...gen.Condition) INoteToPingDo
|
||||
Or(conds ...gen.Condition) INoteToPingDo
|
||||
Select(conds ...field.Expr) INoteToPingDo
|
||||
Where(conds ...gen.Condition) INoteToPingDo
|
||||
Order(conds ...field.Expr) INoteToPingDo
|
||||
Distinct(cols ...field.Expr) INoteToPingDo
|
||||
Omit(cols ...field.Expr) INoteToPingDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteToPingDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo
|
||||
Group(cols ...field.Expr) INoteToPingDo
|
||||
Having(conds ...gen.Condition) INoteToPingDo
|
||||
Limit(limit int) INoteToPingDo
|
||||
Offset(offset int) INoteToPingDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToPingDo
|
||||
Unscoped() INoteToPingDo
|
||||
Create(values ...*models.NoteToPing) error
|
||||
CreateInBatches(values []*models.NoteToPing, batchSize int) error
|
||||
Save(values ...*models.NoteToPing) error
|
||||
First() (*models.NoteToPing, error)
|
||||
Take() (*models.NoteToPing, error)
|
||||
Last() (*models.NoteToPing, error)
|
||||
Find() ([]*models.NoteToPing, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToPing, err error)
|
||||
FindInBatches(result *[]*models.NoteToPing, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.NoteToPing) (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) INoteToPingDo
|
||||
Assign(attrs ...field.AssignExpr) INoteToPingDo
|
||||
Joins(fields ...field.RelationField) INoteToPingDo
|
||||
Preload(fields ...field.RelationField) INoteToPingDo
|
||||
FirstOrInit() (*models.NoteToPing, error)
|
||||
FirstOrCreate() (*models.NoteToPing, error)
|
||||
FindByPage(offset int, limit int) (result []*models.NoteToPing, 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) INoteToPingDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Debug() INoteToPingDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteToPingDo) WithContext(ctx context.Context) INoteToPingDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) ReadDB() INoteToPingDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) WriteDB() INoteToPingDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Session(config *gorm.Session) INoteToPingDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Clauses(conds ...clause.Expression) INoteToPingDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Returning(value interface{}, columns ...string) INoteToPingDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Not(conds ...gen.Condition) INoteToPingDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Or(conds ...gen.Condition) INoteToPingDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Select(conds ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Where(conds ...gen.Condition) INoteToPingDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Order(conds ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Distinct(cols ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Omit(cols ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Join(table schema.Tabler, on ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Group(cols ...field.Expr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Having(conds ...gen.Condition) INoteToPingDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Limit(limit int) INoteToPingDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Offset(offset int) INoteToPingDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteToPingDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Unscoped() INoteToPingDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Create(values ...*models.NoteToPing) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) CreateInBatches(values []*models.NoteToPing, 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 noteToPingDo) Save(values ...*models.NoteToPing) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) First() (*models.NoteToPing, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToPing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Take() (*models.NoteToPing, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToPing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Last() (*models.NoteToPing, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToPing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Find() ([]*models.NoteToPing, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.NoteToPing), err
|
||||
}
|
||||
|
||||
func (n noteToPingDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.NoteToPing, err error) {
|
||||
buf := make([]*models.NoteToPing, 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 noteToPingDo) FindInBatches(result *[]*models.NoteToPing, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Attrs(attrs ...field.AssignExpr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Assign(attrs ...field.AssignExpr) INoteToPingDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Joins(fields ...field.RelationField) INoteToPingDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Preload(fields ...field.RelationField) INoteToPingDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteToPingDo) FirstOrInit() (*models.NoteToPing, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToPing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToPingDo) FirstOrCreate() (*models.NoteToPing, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.NoteToPing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteToPingDo) FindByPage(offset int, limit int) (result []*models.NoteToPing, 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 noteToPingDo) 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 noteToPingDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteToPingDo) Delete(models ...*models.NoteToPing) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteToPingDo) withDO(do gen.Dao) *noteToPingDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
903
storage-new/dbgen/notes.gen.go
Normal file
903
storage-new/dbgen/notes.gen.go
Normal file
|
@ -0,0 +1,903 @@
|
|||
// 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 newNote(db *gorm.DB, opts ...gen.DOOption) note {
|
||||
_note := note{}
|
||||
|
||||
_note.noteDo.UseDB(db, opts...)
|
||||
_note.noteDo.UseModel(&models.Note{})
|
||||
|
||||
tableName := _note.noteDo.TableName()
|
||||
_note.ALL = field.NewAsterisk(tableName)
|
||||
_note.ID = field.NewString(tableName, "id")
|
||||
_note.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_note.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_note.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_note.CreatorId = field.NewString(tableName, "creator_id")
|
||||
_note.Remote = field.NewBool(tableName, "remote")
|
||||
_note.RawContent = field.NewString(tableName, "raw_content")
|
||||
_note.ContentWarning = field.NewString(tableName, "content_warning")
|
||||
_note.RepliesTo = field.NewString(tableName, "replies_to")
|
||||
_note.Quotes = field.NewString(tableName, "quotes")
|
||||
_note.AccessLevel = field.NewField(tableName, "access_level")
|
||||
_note.OriginServer = field.NewString(tableName, "origin_server")
|
||||
_note.AttachmentRelations = noteHasManyAttachmentRelations{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("AttachmentRelations", "models.NoteToAttachment"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
AttachmentRelations struct {
|
||||
field.RelationField
|
||||
}
|
||||
EmoteRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note", "models.Note"),
|
||||
AttachmentRelations: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.AttachmentRelations", "models.NoteToAttachment"),
|
||||
},
|
||||
EmoteRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations", "models.NoteToEmote"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Note", "models.Note"),
|
||||
},
|
||||
Emote: struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote", "models.Emote"),
|
||||
Metadata: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote.Metadata", "models.MediaMetadata"),
|
||||
},
|
||||
Server: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
PingRelations: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.PingRelations", "models.NoteToPing"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.PingRelations.Note", "models.Note"),
|
||||
},
|
||||
PingTarget: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.PingRelations.PingTarget", "models.User"),
|
||||
},
|
||||
},
|
||||
Tags: struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.Tags", "models.NoteTag"),
|
||||
Note: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Note.Tags.Note", "models.Note"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Attachment: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("AttachmentRelations.Attachment", "models.MediaMetadata"),
|
||||
},
|
||||
}
|
||||
|
||||
_note.EmoteRelations = noteHasManyEmoteRelations{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("EmoteRelations", "models.NoteToEmote"),
|
||||
}
|
||||
|
||||
_note.PingRelations = noteHasManyPingRelations{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("PingRelations", "models.NoteToPing"),
|
||||
}
|
||||
|
||||
_note.Tags = noteHasManyTags{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Tags", "models.NoteTag"),
|
||||
}
|
||||
|
||||
_note.fillFieldMap()
|
||||
|
||||
return _note
|
||||
}
|
||||
|
||||
type note struct {
|
||||
noteDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
CreatorId field.String
|
||||
Remote field.Bool
|
||||
RawContent field.String
|
||||
ContentWarning field.String
|
||||
RepliesTo field.String
|
||||
Quotes field.String
|
||||
AccessLevel field.Field
|
||||
OriginServer field.String
|
||||
AttachmentRelations noteHasManyAttachmentRelations
|
||||
|
||||
EmoteRelations noteHasManyEmoteRelations
|
||||
|
||||
PingRelations noteHasManyPingRelations
|
||||
|
||||
Tags noteHasManyTags
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n note) Table(newTableName string) *note {
|
||||
n.noteDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n note) As(alias string) *note {
|
||||
n.noteDo.DO = *(n.noteDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *note) updateTableName(table string) *note {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewString(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
n.DeletedAt = field.NewField(table, "deleted_at")
|
||||
n.CreatorId = field.NewString(table, "creator_id")
|
||||
n.Remote = field.NewBool(table, "remote")
|
||||
n.RawContent = field.NewString(table, "raw_content")
|
||||
n.ContentWarning = field.NewString(table, "content_warning")
|
||||
n.RepliesTo = field.NewString(table, "replies_to")
|
||||
n.Quotes = field.NewString(table, "quotes")
|
||||
n.AccessLevel = field.NewField(table, "access_level")
|
||||
n.OriginServer = field.NewString(table, "origin_server")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *note) 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 *note) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 16)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["updated_at"] = n.UpdatedAt
|
||||
n.fieldMap["deleted_at"] = n.DeletedAt
|
||||
n.fieldMap["creator_id"] = n.CreatorId
|
||||
n.fieldMap["remote"] = n.Remote
|
||||
n.fieldMap["raw_content"] = n.RawContent
|
||||
n.fieldMap["content_warning"] = n.ContentWarning
|
||||
n.fieldMap["replies_to"] = n.RepliesTo
|
||||
n.fieldMap["quotes"] = n.Quotes
|
||||
n.fieldMap["access_level"] = n.AccessLevel
|
||||
n.fieldMap["origin_server"] = n.OriginServer
|
||||
|
||||
}
|
||||
|
||||
func (n note) clone(db *gorm.DB) note {
|
||||
n.noteDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n note) replaceDB(db *gorm.DB) note {
|
||||
n.noteDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type noteHasManyAttachmentRelations struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Note struct {
|
||||
field.RelationField
|
||||
AttachmentRelations struct {
|
||||
field.RelationField
|
||||
}
|
||||
EmoteRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
Emote struct {
|
||||
field.RelationField
|
||||
Metadata struct {
|
||||
field.RelationField
|
||||
}
|
||||
Server struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
Attachment struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelations) Where(conds ...field.Expr) *noteHasManyAttachmentRelations {
|
||||
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 noteHasManyAttachmentRelations) WithContext(ctx context.Context) *noteHasManyAttachmentRelations {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelations) Session(session *gorm.Session) *noteHasManyAttachmentRelations {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelations) Model(m *models.Note) *noteHasManyAttachmentRelationsTx {
|
||||
return ¬eHasManyAttachmentRelationsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteHasManyAttachmentRelationsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Find() (result []*models.NoteToAttachment, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Append(values ...*models.NoteToAttachment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Replace(values ...*models.NoteToAttachment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Delete(values ...*models.NoteToAttachment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteHasManyAttachmentRelationsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteHasManyEmoteRelations struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelations) Where(conds ...field.Expr) *noteHasManyEmoteRelations {
|
||||
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 noteHasManyEmoteRelations) WithContext(ctx context.Context) *noteHasManyEmoteRelations {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelations) Session(session *gorm.Session) *noteHasManyEmoteRelations {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelations) Model(m *models.Note) *noteHasManyEmoteRelationsTx {
|
||||
return ¬eHasManyEmoteRelationsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteHasManyEmoteRelationsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Find() (result []*models.NoteToEmote, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Append(values ...*models.NoteToEmote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Replace(values ...*models.NoteToEmote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Delete(values ...*models.NoteToEmote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteHasManyEmoteRelationsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteHasManyPingRelations struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelations) Where(conds ...field.Expr) *noteHasManyPingRelations {
|
||||
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 noteHasManyPingRelations) WithContext(ctx context.Context) *noteHasManyPingRelations {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelations) Session(session *gorm.Session) *noteHasManyPingRelations {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelations) Model(m *models.Note) *noteHasManyPingRelationsTx {
|
||||
return ¬eHasManyPingRelationsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteHasManyPingRelationsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Find() (result []*models.NoteToPing, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Append(values ...*models.NoteToPing) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Replace(values ...*models.NoteToPing) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Delete(values ...*models.NoteToPing) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteHasManyPingRelationsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteHasManyTags struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a noteHasManyTags) Where(conds ...field.Expr) *noteHasManyTags {
|
||||
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 noteHasManyTags) WithContext(ctx context.Context) *noteHasManyTags {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyTags) Session(session *gorm.Session) *noteHasManyTags {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteHasManyTags) Model(m *models.Note) *noteHasManyTagsTx {
|
||||
return ¬eHasManyTagsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type noteHasManyTagsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteHasManyTagsTx) Find() (result []*models.NoteTag, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteHasManyTagsTx) Append(values ...*models.NoteTag) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyTagsTx) Replace(values ...*models.NoteTag) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyTagsTx) Delete(values ...*models.NoteTag) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteHasManyTagsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteHasManyTagsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type noteDo struct{ gen.DO }
|
||||
|
||||
type INoteDo interface {
|
||||
gen.SubQuery
|
||||
Debug() INoteDo
|
||||
WithContext(ctx context.Context) INoteDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() INoteDo
|
||||
WriteDB() INoteDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) INoteDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) INoteDo
|
||||
Not(conds ...gen.Condition) INoteDo
|
||||
Or(conds ...gen.Condition) INoteDo
|
||||
Select(conds ...field.Expr) INoteDo
|
||||
Where(conds ...gen.Condition) INoteDo
|
||||
Order(conds ...field.Expr) INoteDo
|
||||
Distinct(cols ...field.Expr) INoteDo
|
||||
Omit(cols ...field.Expr) INoteDo
|
||||
Join(table schema.Tabler, on ...field.Expr) INoteDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) INoteDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) INoteDo
|
||||
Group(cols ...field.Expr) INoteDo
|
||||
Having(conds ...gen.Condition) INoteDo
|
||||
Limit(limit int) INoteDo
|
||||
Offset(offset int) INoteDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) INoteDo
|
||||
Unscoped() INoteDo
|
||||
Create(values ...*models.Note) error
|
||||
CreateInBatches(values []*models.Note, batchSize int) error
|
||||
Save(values ...*models.Note) error
|
||||
First() (*models.Note, error)
|
||||
Take() (*models.Note, error)
|
||||
Last() (*models.Note, error)
|
||||
Find() ([]*models.Note, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Note, err error)
|
||||
FindInBatches(result *[]*models.Note, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.Note) (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) INoteDo
|
||||
Assign(attrs ...field.AssignExpr) INoteDo
|
||||
Joins(fields ...field.RelationField) INoteDo
|
||||
Preload(fields ...field.RelationField) INoteDo
|
||||
FirstOrInit() (*models.Note, error)
|
||||
FirstOrCreate() (*models.Note, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Note, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) INoteDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (n noteDo) Debug() INoteDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n noteDo) WithContext(ctx context.Context) INoteDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n noteDo) ReadDB() INoteDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n noteDo) WriteDB() INoteDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n noteDo) Session(config *gorm.Session) INoteDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n noteDo) Clauses(conds ...clause.Expression) INoteDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Returning(value interface{}, columns ...string) INoteDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n noteDo) Not(conds ...gen.Condition) INoteDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Or(conds ...gen.Condition) INoteDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Select(conds ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Where(conds ...gen.Condition) INoteDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Order(conds ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Distinct(cols ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n noteDo) Omit(cols ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n noteDo) Join(table schema.Tabler, on ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n noteDo) LeftJoin(table schema.Tabler, on ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteDo) RightJoin(table schema.Tabler, on ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n noteDo) Group(cols ...field.Expr) INoteDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n noteDo) Having(conds ...gen.Condition) INoteDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n noteDo) Limit(limit int) INoteDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n noteDo) Offset(offset int) INoteDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n noteDo) Scopes(funcs ...func(gen.Dao) gen.Dao) INoteDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n noteDo) Unscoped() INoteDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n noteDo) Create(values ...*models.Note) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n noteDo) CreateInBatches(values []*models.Note, 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 noteDo) Save(values ...*models.Note) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n noteDo) First() (*models.Note, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Note), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteDo) Take() (*models.Note, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Note), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteDo) Last() (*models.Note, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Note), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteDo) Find() ([]*models.Note, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.Note), err
|
||||
}
|
||||
|
||||
func (n noteDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Note, err error) {
|
||||
buf := make([]*models.Note, 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 noteDo) FindInBatches(result *[]*models.Note, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n noteDo) Attrs(attrs ...field.AssignExpr) INoteDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n noteDo) Assign(attrs ...field.AssignExpr) INoteDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n noteDo) Joins(fields ...field.RelationField) INoteDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteDo) Preload(fields ...field.RelationField) INoteDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n noteDo) FirstOrInit() (*models.Note, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Note), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteDo) FirstOrCreate() (*models.Note, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Note), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n noteDo) FindByPage(offset int, limit int) (result []*models.Note, 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 noteDo) 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 noteDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n noteDo) Delete(models ...*models.Note) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *noteDo) withDO(do gen.Dao) *noteDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
777
storage-new/dbgen/reactions.gen.go
Normal file
777
storage-new/dbgen/reactions.gen.go
Normal file
|
@ -0,0 +1,777 @@
|
|||
// 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 newReaction(db *gorm.DB, opts ...gen.DOOption) reaction {
|
||||
_reaction := reaction{}
|
||||
|
||||
_reaction.reactionDo.UseDB(db, opts...)
|
||||
_reaction.reactionDo.UseModel(&models.Reaction{})
|
||||
|
||||
tableName := _reaction.reactionDo.TableName()
|
||||
_reaction.ALL = field.NewAsterisk(tableName)
|
||||
_reaction.ID = field.NewUint(tableName, "id")
|
||||
_reaction.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_reaction.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_reaction.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_reaction.NoteId = field.NewString(tableName, "note_id")
|
||||
_reaction.ReactorId = field.NewString(tableName, "reactor_id")
|
||||
_reaction.EmoteId = field.NewUint(tableName, "emote_id")
|
||||
_reaction.Note = reactionBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Note", "models.Note"),
|
||||
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
|
||||
}
|
||||
}
|
||||
}{
|
||||
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
|
||||
}
|
||||
}{
|
||||
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
|
||||
}{
|
||||
RelationField: field.NewRelation("Note.EmoteRelations.Emote.Server", "models.RemoteServer"),
|
||||
},
|
||||
},
|
||||
},
|
||||
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"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
_reaction.Reactor = reactionBelongsToReactor{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Reactor", "models.User"),
|
||||
}
|
||||
|
||||
_reaction.Emote = reactionBelongsToEmote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Emote", "models.Emote"),
|
||||
}
|
||||
|
||||
_reaction.fillFieldMap()
|
||||
|
||||
return _reaction
|
||||
}
|
||||
|
||||
type reaction struct {
|
||||
reactionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
NoteId field.String
|
||||
ReactorId field.String
|
||||
EmoteId field.Uint
|
||||
Note reactionBelongsToNote
|
||||
|
||||
Reactor reactionBelongsToReactor
|
||||
|
||||
Emote reactionBelongsToEmote
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r reaction) Table(newTableName string) *reaction {
|
||||
r.reactionDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r reaction) As(alias string) *reaction {
|
||||
r.reactionDo.DO = *(r.reactionDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *reaction) updateTableName(table string) *reaction {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewUint(table, "id")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
r.NoteId = field.NewString(table, "note_id")
|
||||
r.ReactorId = field.NewString(table, "reactor_id")
|
||||
r.EmoteId = field.NewUint(table, "emote_id")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *reaction) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *reaction) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 10)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
r.fieldMap["note_id"] = r.NoteId
|
||||
r.fieldMap["reactor_id"] = r.ReactorId
|
||||
r.fieldMap["emote_id"] = r.EmoteId
|
||||
|
||||
}
|
||||
|
||||
func (r reaction) clone(db *gorm.DB) reaction {
|
||||
r.reactionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r reaction) replaceDB(db *gorm.DB) reaction {
|
||||
r.reactionDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type reactionBelongsToNote struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
PingRelations struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
PingTarget struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
Tags struct {
|
||||
field.RelationField
|
||||
Note struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNote) Where(conds ...field.Expr) *reactionBelongsToNote {
|
||||
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 reactionBelongsToNote) WithContext(ctx context.Context) *reactionBelongsToNote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNote) Session(session *gorm.Session) *reactionBelongsToNote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNote) Model(m *models.Reaction) *reactionBelongsToNoteTx {
|
||||
return &reactionBelongsToNoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type reactionBelongsToNoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToNoteTx) Find() (result *models.Note, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNoteTx) 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 reactionBelongsToNoteTx) 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 reactionBelongsToNoteTx) 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 reactionBelongsToNoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToNoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type reactionBelongsToReactor struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactor) Where(conds ...field.Expr) *reactionBelongsToReactor {
|
||||
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 reactionBelongsToReactor) WithContext(ctx context.Context) *reactionBelongsToReactor {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactor) Session(session *gorm.Session) *reactionBelongsToReactor {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactor) Model(m *models.Reaction) *reactionBelongsToReactorTx {
|
||||
return &reactionBelongsToReactorTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type reactionBelongsToReactorTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToReactorTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactorTx) 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 reactionBelongsToReactorTx) 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 reactionBelongsToReactorTx) 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 reactionBelongsToReactorTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToReactorTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type reactionBelongsToEmote struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmote) Where(conds ...field.Expr) *reactionBelongsToEmote {
|
||||
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 reactionBelongsToEmote) WithContext(ctx context.Context) *reactionBelongsToEmote {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmote) Session(session *gorm.Session) *reactionBelongsToEmote {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmote) Model(m *models.Reaction) *reactionBelongsToEmoteTx {
|
||||
return &reactionBelongsToEmoteTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type reactionBelongsToEmoteTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Find() (result *models.Emote, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Append(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Replace(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Delete(values ...*models.Emote) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a reactionBelongsToEmoteTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type reactionDo struct{ gen.DO }
|
||||
|
||||
type IReactionDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IReactionDo
|
||||
WithContext(ctx context.Context) IReactionDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IReactionDo
|
||||
WriteDB() IReactionDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IReactionDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IReactionDo
|
||||
Not(conds ...gen.Condition) IReactionDo
|
||||
Or(conds ...gen.Condition) IReactionDo
|
||||
Select(conds ...field.Expr) IReactionDo
|
||||
Where(conds ...gen.Condition) IReactionDo
|
||||
Order(conds ...field.Expr) IReactionDo
|
||||
Distinct(cols ...field.Expr) IReactionDo
|
||||
Omit(cols ...field.Expr) IReactionDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IReactionDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IReactionDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IReactionDo
|
||||
Group(cols ...field.Expr) IReactionDo
|
||||
Having(conds ...gen.Condition) IReactionDo
|
||||
Limit(limit int) IReactionDo
|
||||
Offset(offset int) IReactionDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IReactionDo
|
||||
Unscoped() IReactionDo
|
||||
Create(values ...*models.Reaction) error
|
||||
CreateInBatches(values []*models.Reaction, batchSize int) error
|
||||
Save(values ...*models.Reaction) error
|
||||
First() (*models.Reaction, error)
|
||||
Take() (*models.Reaction, error)
|
||||
Last() (*models.Reaction, error)
|
||||
Find() ([]*models.Reaction, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Reaction, err error)
|
||||
FindInBatches(result *[]*models.Reaction, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.Reaction) (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) IReactionDo
|
||||
Assign(attrs ...field.AssignExpr) IReactionDo
|
||||
Joins(fields ...field.RelationField) IReactionDo
|
||||
Preload(fields ...field.RelationField) IReactionDo
|
||||
FirstOrInit() (*models.Reaction, error)
|
||||
FirstOrCreate() (*models.Reaction, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Reaction, 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) IReactionDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (r reactionDo) Debug() IReactionDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r reactionDo) WithContext(ctx context.Context) IReactionDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r reactionDo) ReadDB() IReactionDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r reactionDo) WriteDB() IReactionDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r reactionDo) Session(config *gorm.Session) IReactionDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r reactionDo) Clauses(conds ...clause.Expression) IReactionDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Returning(value interface{}, columns ...string) IReactionDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Not(conds ...gen.Condition) IReactionDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Or(conds ...gen.Condition) IReactionDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Select(conds ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Where(conds ...gen.Condition) IReactionDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Order(conds ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Distinct(cols ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Omit(cols ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Join(table schema.Tabler, on ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r reactionDo) LeftJoin(table schema.Tabler, on ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r reactionDo) RightJoin(table schema.Tabler, on ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Group(cols ...field.Expr) IReactionDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Having(conds ...gen.Condition) IReactionDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Limit(limit int) IReactionDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r reactionDo) Offset(offset int) IReactionDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r reactionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IReactionDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Unscoped() IReactionDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r reactionDo) Create(values ...*models.Reaction) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r reactionDo) CreateInBatches(values []*models.Reaction, batchSize int) error {
|
||||
return r.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 (r reactionDo) Save(values ...*models.Reaction) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r reactionDo) First() (*models.Reaction, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Reaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r reactionDo) Take() (*models.Reaction, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Reaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r reactionDo) Last() (*models.Reaction, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Reaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r reactionDo) Find() ([]*models.Reaction, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.Reaction), err
|
||||
}
|
||||
|
||||
func (r reactionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Reaction, err error) {
|
||||
buf := make([]*models.Reaction, 0, batchSize)
|
||||
err = r.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 (r reactionDo) FindInBatches(result *[]*models.Reaction, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r reactionDo) Attrs(attrs ...field.AssignExpr) IReactionDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Assign(attrs ...field.AssignExpr) IReactionDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r reactionDo) Joins(fields ...field.RelationField) IReactionDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r reactionDo) Preload(fields ...field.RelationField) IReactionDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r reactionDo) FirstOrInit() (*models.Reaction, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Reaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r reactionDo) FirstOrCreate() (*models.Reaction, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Reaction), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r reactionDo) FindByPage(offset int, limit int) (result []*models.Reaction, count int64, err error) {
|
||||
result, err = r.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 = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r reactionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r reactionDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r reactionDo) Delete(models ...*models.Reaction) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *reactionDo) withDO(do gen.Dao) *reactionDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
411
storage-new/dbgen/remote_servers.gen.go
Normal file
411
storage-new/dbgen/remote_servers.gen.go
Normal file
|
@ -0,0 +1,411 @@
|
|||
// 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 newRemoteServer(db *gorm.DB, opts ...gen.DOOption) remoteServer {
|
||||
_remoteServer := remoteServer{}
|
||||
|
||||
_remoteServer.remoteServerDo.UseDB(db, opts...)
|
||||
_remoteServer.remoteServerDo.UseModel(&models.RemoteServer{})
|
||||
|
||||
tableName := _remoteServer.remoteServerDo.TableName()
|
||||
_remoteServer.ALL = field.NewAsterisk(tableName)
|
||||
_remoteServer.ID = field.NewUint(tableName, "id")
|
||||
_remoteServer.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_remoteServer.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_remoteServer.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_remoteServer.ServerType = field.NewField(tableName, "server_type")
|
||||
_remoteServer.Domain = field.NewString(tableName, "domain")
|
||||
_remoteServer.Name = field.NewString(tableName, "name")
|
||||
_remoteServer.Icon = field.NewString(tableName, "icon")
|
||||
_remoteServer.IsSelf = field.NewBool(tableName, "is_self")
|
||||
|
||||
_remoteServer.fillFieldMap()
|
||||
|
||||
return _remoteServer
|
||||
}
|
||||
|
||||
type remoteServer struct {
|
||||
remoteServerDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
ServerType field.Field
|
||||
Domain field.String
|
||||
Name field.String
|
||||
Icon field.String
|
||||
IsSelf field.Bool
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r remoteServer) Table(newTableName string) *remoteServer {
|
||||
r.remoteServerDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r remoteServer) As(alias string) *remoteServer {
|
||||
r.remoteServerDo.DO = *(r.remoteServerDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *remoteServer) updateTableName(table string) *remoteServer {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewUint(table, "id")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
r.ServerType = field.NewField(table, "server_type")
|
||||
r.Domain = field.NewString(table, "domain")
|
||||
r.Name = field.NewString(table, "name")
|
||||
r.Icon = field.NewString(table, "icon")
|
||||
r.IsSelf = field.NewBool(table, "is_self")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *remoteServer) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *remoteServer) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 9)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
r.fieldMap["server_type"] = r.ServerType
|
||||
r.fieldMap["domain"] = r.Domain
|
||||
r.fieldMap["name"] = r.Name
|
||||
r.fieldMap["icon"] = r.Icon
|
||||
r.fieldMap["is_self"] = r.IsSelf
|
||||
}
|
||||
|
||||
func (r remoteServer) clone(db *gorm.DB) remoteServer {
|
||||
r.remoteServerDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r remoteServer) replaceDB(db *gorm.DB) remoteServer {
|
||||
r.remoteServerDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type remoteServerDo struct{ gen.DO }
|
||||
|
||||
type IRemoteServerDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IRemoteServerDo
|
||||
WithContext(ctx context.Context) IRemoteServerDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IRemoteServerDo
|
||||
WriteDB() IRemoteServerDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IRemoteServerDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IRemoteServerDo
|
||||
Not(conds ...gen.Condition) IRemoteServerDo
|
||||
Or(conds ...gen.Condition) IRemoteServerDo
|
||||
Select(conds ...field.Expr) IRemoteServerDo
|
||||
Where(conds ...gen.Condition) IRemoteServerDo
|
||||
Order(conds ...field.Expr) IRemoteServerDo
|
||||
Distinct(cols ...field.Expr) IRemoteServerDo
|
||||
Omit(cols ...field.Expr) IRemoteServerDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IRemoteServerDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IRemoteServerDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IRemoteServerDo
|
||||
Group(cols ...field.Expr) IRemoteServerDo
|
||||
Having(conds ...gen.Condition) IRemoteServerDo
|
||||
Limit(limit int) IRemoteServerDo
|
||||
Offset(offset int) IRemoteServerDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IRemoteServerDo
|
||||
Unscoped() IRemoteServerDo
|
||||
Create(values ...*models.RemoteServer) error
|
||||
CreateInBatches(values []*models.RemoteServer, batchSize int) error
|
||||
Save(values ...*models.RemoteServer) error
|
||||
First() (*models.RemoteServer, error)
|
||||
Take() (*models.RemoteServer, error)
|
||||
Last() (*models.RemoteServer, error)
|
||||
Find() ([]*models.RemoteServer, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.RemoteServer, err error)
|
||||
FindInBatches(result *[]*models.RemoteServer, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.RemoteServer) (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) IRemoteServerDo
|
||||
Assign(attrs ...field.AssignExpr) IRemoteServerDo
|
||||
Joins(fields ...field.RelationField) IRemoteServerDo
|
||||
Preload(fields ...field.RelationField) IRemoteServerDo
|
||||
FirstOrInit() (*models.RemoteServer, error)
|
||||
FirstOrCreate() (*models.RemoteServer, error)
|
||||
FindByPage(offset int, limit int) (result []*models.RemoteServer, 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) IRemoteServerDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Debug() IRemoteServerDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r remoteServerDo) WithContext(ctx context.Context) IRemoteServerDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) ReadDB() IRemoteServerDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) WriteDB() IRemoteServerDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Session(config *gorm.Session) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Clauses(conds ...clause.Expression) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Returning(value interface{}, columns ...string) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Not(conds ...gen.Condition) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Or(conds ...gen.Condition) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Select(conds ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Where(conds ...gen.Condition) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Order(conds ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Distinct(cols ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Omit(cols ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Join(table schema.Tabler, on ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) LeftJoin(table schema.Tabler, on ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) RightJoin(table schema.Tabler, on ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Group(cols ...field.Expr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Having(conds ...gen.Condition) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Limit(limit int) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Offset(offset int) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Unscoped() IRemoteServerDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Create(values ...*models.RemoteServer) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) CreateInBatches(values []*models.RemoteServer, batchSize int) error {
|
||||
return r.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 (r remoteServerDo) Save(values ...*models.RemoteServer) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) First() (*models.RemoteServer, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.RemoteServer), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Take() (*models.RemoteServer, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.RemoteServer), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Last() (*models.RemoteServer, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.RemoteServer), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Find() ([]*models.RemoteServer, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.RemoteServer), err
|
||||
}
|
||||
|
||||
func (r remoteServerDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.RemoteServer, err error) {
|
||||
buf := make([]*models.RemoteServer, 0, batchSize)
|
||||
err = r.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 (r remoteServerDo) FindInBatches(result *[]*models.RemoteServer, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Attrs(attrs ...field.AssignExpr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Assign(attrs ...field.AssignExpr) IRemoteServerDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Joins(fields ...field.RelationField) IRemoteServerDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Preload(fields ...field.RelationField) IRemoteServerDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r remoteServerDo) FirstOrInit() (*models.RemoteServer, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.RemoteServer), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r remoteServerDo) FirstOrCreate() (*models.RemoteServer, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.RemoteServer), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r remoteServerDo) FindByPage(offset int, limit int) (result []*models.RemoteServer, count int64, err error) {
|
||||
result, err = r.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 = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r remoteServerDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r remoteServerDo) Delete(models ...*models.RemoteServer) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *remoteServerDo) withDO(do gen.Dao) *remoteServerDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
587
storage-new/dbgen/roles.gen.go
Normal file
587
storage-new/dbgen/roles.gen.go
Normal file
|
@ -0,0 +1,587 @@
|
|||
// 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 newRole(db *gorm.DB, opts ...gen.DOOption) role {
|
||||
_role := role{}
|
||||
|
||||
_role.roleDo.UseDB(db, opts...)
|
||||
_role.roleDo.UseModel(&models.Role{})
|
||||
|
||||
tableName := _role.roleDo.TableName()
|
||||
_role.ALL = field.NewAsterisk(tableName)
|
||||
_role.ID = field.NewUint(tableName, "id")
|
||||
_role.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_role.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_role.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_role.Name = field.NewString(tableName, "name")
|
||||
_role.Priority = field.NewUint32(tableName, "priority")
|
||||
_role.IsUserRole = field.NewBool(tableName, "is_user_role")
|
||||
_role.IsBuiltIn = field.NewBool(tableName, "is_built_in")
|
||||
_role.CanSendMedia = field.NewBool(tableName, "can_send_media")
|
||||
_role.CanSendCustomEmotes = field.NewBool(tableName, "can_send_custom_emotes")
|
||||
_role.CanSendCustomReactions = field.NewBool(tableName, "can_send_custom_reactions")
|
||||
_role.CanSendPublicNotes = field.NewBool(tableName, "can_send_public_notes")
|
||||
_role.CanSendLocalNotes = field.NewBool(tableName, "can_send_local_notes")
|
||||
_role.CanSendFollowerOnlyNotes = field.NewBool(tableName, "can_send_follower_only_notes")
|
||||
_role.CanSendPrivateNotes = field.NewBool(tableName, "can_send_private_notes")
|
||||
_role.CanSendReplies = field.NewBool(tableName, "can_send_replies")
|
||||
_role.CanQuote = field.NewBool(tableName, "can_quote")
|
||||
_role.CanBoost = field.NewBool(tableName, "can_boost")
|
||||
_role.CanIncludeLinks = field.NewBool(tableName, "can_include_links")
|
||||
_role.CanIncludeSurvey = field.NewBool(tableName, "can_include_survey")
|
||||
_role.CanFederateFedi = field.NewBool(tableName, "can_federate_fedi")
|
||||
_role.CanFederateBsky = field.NewBool(tableName, "can_federate_bsky")
|
||||
_role.CanChangeDisplayName = field.NewBool(tableName, "can_change_display_name")
|
||||
_role.CanSubmitReports = field.NewBool(tableName, "can_submit_reports")
|
||||
_role.CanLogin = field.NewBool(tableName, "can_login")
|
||||
_role.CanMentionOthers = field.NewBool(tableName, "can_mention_others")
|
||||
_role.HasMentionCountLimit = field.NewBool(tableName, "has_mention_count_limit")
|
||||
_role.MentionLimit = field.NewUint32(tableName, "mention_limit")
|
||||
_role.AutoNsfwMedia = field.NewBool(tableName, "auto_nsfw_media")
|
||||
_role.AutoCwPosts = field.NewBool(tableName, "auto_cw_posts")
|
||||
_role.AutoCwPostsText = field.NewString(tableName, "auto_cw_posts_text")
|
||||
_role.ScanCreatedPublicNotes = field.NewBool(tableName, "scan_created_public_notes")
|
||||
_role.ScanCreatedLocalNotes = field.NewBool(tableName, "scan_created_local_notes")
|
||||
_role.ScanCreatedFollowerOnlyNotes = field.NewBool(tableName, "scan_created_follower_only_notes")
|
||||
_role.ScanCreatedPrivateNotes = field.NewBool(tableName, "scan_created_private_notes")
|
||||
_role.DisallowInteractionsWith = field.NewField(tableName, "disallow_interactions_with")
|
||||
_role.WithholdNotesForManualApproval = field.NewBool(tableName, "withhold_notes_for_manual_approval")
|
||||
_role.WithholdNotesBasedOnRegex = field.NewBool(tableName, "withhold_notes_based_on_regex")
|
||||
_role.WithholdNotesRegexes = field.NewField(tableName, "withhold_notes_regexes")
|
||||
_role.FullAdmin = field.NewBool(tableName, "full_admin")
|
||||
_role.CanAffectOtherAdmins = field.NewBool(tableName, "can_affect_other_admins")
|
||||
_role.CanDeleteNotes = field.NewBool(tableName, "can_delete_notes")
|
||||
_role.CanConfirmWithheldNotes = field.NewBool(tableName, "can_confirm_withheld_notes")
|
||||
_role.CanAssignRoles = field.NewBool(tableName, "can_assign_roles")
|
||||
_role.CanSupressInteractionsBetweenUsers = field.NewBool(tableName, "can_supress_interactions_between_users")
|
||||
_role.CanOverwriteDisplayNames = field.NewBool(tableName, "can_overwrite_display_names")
|
||||
_role.CanManageCustomEmotes = field.NewBool(tableName, "can_manage_custom_emotes")
|
||||
_role.CanViewDeletedNotes = field.NewBool(tableName, "can_view_deleted_notes")
|
||||
_role.CanRecoverDeletedNotes = field.NewBool(tableName, "can_recover_deleted_notes")
|
||||
_role.CanManageAvatarDecorations = field.NewBool(tableName, "can_manage_avatar_decorations")
|
||||
_role.CanManageAds = field.NewBool(tableName, "can_manage_ads")
|
||||
_role.CanSendAnnouncements = field.NewBool(tableName, "can_send_announcements")
|
||||
_role.CanDeleteAccounts = field.NewBool(tableName, "can_delete_accounts")
|
||||
|
||||
_role.fillFieldMap()
|
||||
|
||||
return _role
|
||||
}
|
||||
|
||||
type role struct {
|
||||
roleDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
Priority field.Uint32
|
||||
IsUserRole field.Bool
|
||||
IsBuiltIn field.Bool
|
||||
CanSendMedia field.Bool
|
||||
CanSendCustomEmotes field.Bool
|
||||
CanSendCustomReactions field.Bool
|
||||
CanSendPublicNotes field.Bool
|
||||
CanSendLocalNotes field.Bool
|
||||
CanSendFollowerOnlyNotes field.Bool
|
||||
CanSendPrivateNotes field.Bool
|
||||
CanSendReplies field.Bool
|
||||
CanQuote field.Bool
|
||||
CanBoost field.Bool
|
||||
CanIncludeLinks field.Bool
|
||||
CanIncludeSurvey field.Bool
|
||||
CanFederateFedi field.Bool
|
||||
CanFederateBsky field.Bool
|
||||
CanChangeDisplayName field.Bool
|
||||
CanSubmitReports field.Bool
|
||||
CanLogin field.Bool
|
||||
CanMentionOthers field.Bool
|
||||
HasMentionCountLimit field.Bool
|
||||
MentionLimit field.Uint32
|
||||
AutoNsfwMedia field.Bool
|
||||
AutoCwPosts field.Bool
|
||||
AutoCwPostsText field.String
|
||||
ScanCreatedPublicNotes field.Bool
|
||||
ScanCreatedLocalNotes field.Bool
|
||||
ScanCreatedFollowerOnlyNotes field.Bool
|
||||
ScanCreatedPrivateNotes field.Bool
|
||||
DisallowInteractionsWith field.Field
|
||||
WithholdNotesForManualApproval field.Bool
|
||||
WithholdNotesBasedOnRegex field.Bool
|
||||
WithholdNotesRegexes field.Field
|
||||
FullAdmin field.Bool
|
||||
CanAffectOtherAdmins field.Bool
|
||||
CanDeleteNotes field.Bool
|
||||
CanConfirmWithheldNotes field.Bool
|
||||
CanAssignRoles field.Bool
|
||||
CanSupressInteractionsBetweenUsers field.Bool
|
||||
CanOverwriteDisplayNames field.Bool
|
||||
CanManageCustomEmotes field.Bool
|
||||
CanViewDeletedNotes field.Bool
|
||||
CanRecoverDeletedNotes field.Bool
|
||||
CanManageAvatarDecorations field.Bool
|
||||
CanManageAds field.Bool
|
||||
CanSendAnnouncements field.Bool
|
||||
CanDeleteAccounts field.Bool
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r role) Table(newTableName string) *role {
|
||||
r.roleDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r role) As(alias string) *role {
|
||||
r.roleDo.DO = *(r.roleDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *role) updateTableName(table string) *role {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewUint(table, "id")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
r.Name = field.NewString(table, "name")
|
||||
r.Priority = field.NewUint32(table, "priority")
|
||||
r.IsUserRole = field.NewBool(table, "is_user_role")
|
||||
r.IsBuiltIn = field.NewBool(table, "is_built_in")
|
||||
r.CanSendMedia = field.NewBool(table, "can_send_media")
|
||||
r.CanSendCustomEmotes = field.NewBool(table, "can_send_custom_emotes")
|
||||
r.CanSendCustomReactions = field.NewBool(table, "can_send_custom_reactions")
|
||||
r.CanSendPublicNotes = field.NewBool(table, "can_send_public_notes")
|
||||
r.CanSendLocalNotes = field.NewBool(table, "can_send_local_notes")
|
||||
r.CanSendFollowerOnlyNotes = field.NewBool(table, "can_send_follower_only_notes")
|
||||
r.CanSendPrivateNotes = field.NewBool(table, "can_send_private_notes")
|
||||
r.CanSendReplies = field.NewBool(table, "can_send_replies")
|
||||
r.CanQuote = field.NewBool(table, "can_quote")
|
||||
r.CanBoost = field.NewBool(table, "can_boost")
|
||||
r.CanIncludeLinks = field.NewBool(table, "can_include_links")
|
||||
r.CanIncludeSurvey = field.NewBool(table, "can_include_survey")
|
||||
r.CanFederateFedi = field.NewBool(table, "can_federate_fedi")
|
||||
r.CanFederateBsky = field.NewBool(table, "can_federate_bsky")
|
||||
r.CanChangeDisplayName = field.NewBool(table, "can_change_display_name")
|
||||
r.CanSubmitReports = field.NewBool(table, "can_submit_reports")
|
||||
r.CanLogin = field.NewBool(table, "can_login")
|
||||
r.CanMentionOthers = field.NewBool(table, "can_mention_others")
|
||||
r.HasMentionCountLimit = field.NewBool(table, "has_mention_count_limit")
|
||||
r.MentionLimit = field.NewUint32(table, "mention_limit")
|
||||
r.AutoNsfwMedia = field.NewBool(table, "auto_nsfw_media")
|
||||
r.AutoCwPosts = field.NewBool(table, "auto_cw_posts")
|
||||
r.AutoCwPostsText = field.NewString(table, "auto_cw_posts_text")
|
||||
r.ScanCreatedPublicNotes = field.NewBool(table, "scan_created_public_notes")
|
||||
r.ScanCreatedLocalNotes = field.NewBool(table, "scan_created_local_notes")
|
||||
r.ScanCreatedFollowerOnlyNotes = field.NewBool(table, "scan_created_follower_only_notes")
|
||||
r.ScanCreatedPrivateNotes = field.NewBool(table, "scan_created_private_notes")
|
||||
r.DisallowInteractionsWith = field.NewField(table, "disallow_interactions_with")
|
||||
r.WithholdNotesForManualApproval = field.NewBool(table, "withhold_notes_for_manual_approval")
|
||||
r.WithholdNotesBasedOnRegex = field.NewBool(table, "withhold_notes_based_on_regex")
|
||||
r.WithholdNotesRegexes = field.NewField(table, "withhold_notes_regexes")
|
||||
r.FullAdmin = field.NewBool(table, "full_admin")
|
||||
r.CanAffectOtherAdmins = field.NewBool(table, "can_affect_other_admins")
|
||||
r.CanDeleteNotes = field.NewBool(table, "can_delete_notes")
|
||||
r.CanConfirmWithheldNotes = field.NewBool(table, "can_confirm_withheld_notes")
|
||||
r.CanAssignRoles = field.NewBool(table, "can_assign_roles")
|
||||
r.CanSupressInteractionsBetweenUsers = field.NewBool(table, "can_supress_interactions_between_users")
|
||||
r.CanOverwriteDisplayNames = field.NewBool(table, "can_overwrite_display_names")
|
||||
r.CanManageCustomEmotes = field.NewBool(table, "can_manage_custom_emotes")
|
||||
r.CanViewDeletedNotes = field.NewBool(table, "can_view_deleted_notes")
|
||||
r.CanRecoverDeletedNotes = field.NewBool(table, "can_recover_deleted_notes")
|
||||
r.CanManageAvatarDecorations = field.NewBool(table, "can_manage_avatar_decorations")
|
||||
r.CanManageAds = field.NewBool(table, "can_manage_ads")
|
||||
r.CanSendAnnouncements = field.NewBool(table, "can_send_announcements")
|
||||
r.CanDeleteAccounts = field.NewBool(table, "can_delete_accounts")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *role) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *role) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 53)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
r.fieldMap["name"] = r.Name
|
||||
r.fieldMap["priority"] = r.Priority
|
||||
r.fieldMap["is_user_role"] = r.IsUserRole
|
||||
r.fieldMap["is_built_in"] = r.IsBuiltIn
|
||||
r.fieldMap["can_send_media"] = r.CanSendMedia
|
||||
r.fieldMap["can_send_custom_emotes"] = r.CanSendCustomEmotes
|
||||
r.fieldMap["can_send_custom_reactions"] = r.CanSendCustomReactions
|
||||
r.fieldMap["can_send_public_notes"] = r.CanSendPublicNotes
|
||||
r.fieldMap["can_send_local_notes"] = r.CanSendLocalNotes
|
||||
r.fieldMap["can_send_follower_only_notes"] = r.CanSendFollowerOnlyNotes
|
||||
r.fieldMap["can_send_private_notes"] = r.CanSendPrivateNotes
|
||||
r.fieldMap["can_send_replies"] = r.CanSendReplies
|
||||
r.fieldMap["can_quote"] = r.CanQuote
|
||||
r.fieldMap["can_boost"] = r.CanBoost
|
||||
r.fieldMap["can_include_links"] = r.CanIncludeLinks
|
||||
r.fieldMap["can_include_survey"] = r.CanIncludeSurvey
|
||||
r.fieldMap["can_federate_fedi"] = r.CanFederateFedi
|
||||
r.fieldMap["can_federate_bsky"] = r.CanFederateBsky
|
||||
r.fieldMap["can_change_display_name"] = r.CanChangeDisplayName
|
||||
r.fieldMap["can_submit_reports"] = r.CanSubmitReports
|
||||
r.fieldMap["can_login"] = r.CanLogin
|
||||
r.fieldMap["can_mention_others"] = r.CanMentionOthers
|
||||
r.fieldMap["has_mention_count_limit"] = r.HasMentionCountLimit
|
||||
r.fieldMap["mention_limit"] = r.MentionLimit
|
||||
r.fieldMap["auto_nsfw_media"] = r.AutoNsfwMedia
|
||||
r.fieldMap["auto_cw_posts"] = r.AutoCwPosts
|
||||
r.fieldMap["auto_cw_posts_text"] = r.AutoCwPostsText
|
||||
r.fieldMap["scan_created_public_notes"] = r.ScanCreatedPublicNotes
|
||||
r.fieldMap["scan_created_local_notes"] = r.ScanCreatedLocalNotes
|
||||
r.fieldMap["scan_created_follower_only_notes"] = r.ScanCreatedFollowerOnlyNotes
|
||||
r.fieldMap["scan_created_private_notes"] = r.ScanCreatedPrivateNotes
|
||||
r.fieldMap["disallow_interactions_with"] = r.DisallowInteractionsWith
|
||||
r.fieldMap["withhold_notes_for_manual_approval"] = r.WithholdNotesForManualApproval
|
||||
r.fieldMap["withhold_notes_based_on_regex"] = r.WithholdNotesBasedOnRegex
|
||||
r.fieldMap["withhold_notes_regexes"] = r.WithholdNotesRegexes
|
||||
r.fieldMap["full_admin"] = r.FullAdmin
|
||||
r.fieldMap["can_affect_other_admins"] = r.CanAffectOtherAdmins
|
||||
r.fieldMap["can_delete_notes"] = r.CanDeleteNotes
|
||||
r.fieldMap["can_confirm_withheld_notes"] = r.CanConfirmWithheldNotes
|
||||
r.fieldMap["can_assign_roles"] = r.CanAssignRoles
|
||||
r.fieldMap["can_supress_interactions_between_users"] = r.CanSupressInteractionsBetweenUsers
|
||||
r.fieldMap["can_overwrite_display_names"] = r.CanOverwriteDisplayNames
|
||||
r.fieldMap["can_manage_custom_emotes"] = r.CanManageCustomEmotes
|
||||
r.fieldMap["can_view_deleted_notes"] = r.CanViewDeletedNotes
|
||||
r.fieldMap["can_recover_deleted_notes"] = r.CanRecoverDeletedNotes
|
||||
r.fieldMap["can_manage_avatar_decorations"] = r.CanManageAvatarDecorations
|
||||
r.fieldMap["can_manage_ads"] = r.CanManageAds
|
||||
r.fieldMap["can_send_announcements"] = r.CanSendAnnouncements
|
||||
r.fieldMap["can_delete_accounts"] = r.CanDeleteAccounts
|
||||
}
|
||||
|
||||
func (r role) clone(db *gorm.DB) role {
|
||||
r.roleDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r role) replaceDB(db *gorm.DB) role {
|
||||
r.roleDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type roleDo struct{ gen.DO }
|
||||
|
||||
type IRoleDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IRoleDo
|
||||
WithContext(ctx context.Context) IRoleDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IRoleDo
|
||||
WriteDB() IRoleDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IRoleDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IRoleDo
|
||||
Not(conds ...gen.Condition) IRoleDo
|
||||
Or(conds ...gen.Condition) IRoleDo
|
||||
Select(conds ...field.Expr) IRoleDo
|
||||
Where(conds ...gen.Condition) IRoleDo
|
||||
Order(conds ...field.Expr) IRoleDo
|
||||
Distinct(cols ...field.Expr) IRoleDo
|
||||
Omit(cols ...field.Expr) IRoleDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IRoleDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo
|
||||
Group(cols ...field.Expr) IRoleDo
|
||||
Having(conds ...gen.Condition) IRoleDo
|
||||
Limit(limit int) IRoleDo
|
||||
Offset(offset int) IRoleDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo
|
||||
Unscoped() IRoleDo
|
||||
Create(values ...*models.Role) error
|
||||
CreateInBatches(values []*models.Role, batchSize int) error
|
||||
Save(values ...*models.Role) error
|
||||
First() (*models.Role, error)
|
||||
Take() (*models.Role, error)
|
||||
Last() (*models.Role, error)
|
||||
Find() ([]*models.Role, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Role, err error)
|
||||
FindInBatches(result *[]*models.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.Role) (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) IRoleDo
|
||||
Assign(attrs ...field.AssignExpr) IRoleDo
|
||||
Joins(fields ...field.RelationField) IRoleDo
|
||||
Preload(fields ...field.RelationField) IRoleDo
|
||||
FirstOrInit() (*models.Role, error)
|
||||
FirstOrCreate() (*models.Role, error)
|
||||
FindByPage(offset int, limit int) (result []*models.Role, 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) IRoleDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (r roleDo) Debug() IRoleDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r roleDo) WithContext(ctx context.Context) IRoleDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r roleDo) ReadDB() IRoleDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r roleDo) WriteDB() IRoleDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r roleDo) Session(config *gorm.Session) IRoleDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r roleDo) Clauses(conds ...clause.Expression) IRoleDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Returning(value interface{}, columns ...string) IRoleDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r roleDo) Not(conds ...gen.Condition) IRoleDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Or(conds ...gen.Condition) IRoleDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Select(conds ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Where(conds ...gen.Condition) IRoleDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Order(conds ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Distinct(cols ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r roleDo) Omit(cols ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r roleDo) Join(table schema.Tabler, on ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r roleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r roleDo) RightJoin(table schema.Tabler, on ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r roleDo) Group(cols ...field.Expr) IRoleDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r roleDo) Having(conds ...gen.Condition) IRoleDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r roleDo) Limit(limit int) IRoleDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r roleDo) Offset(offset int) IRoleDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r roleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IRoleDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r roleDo) Unscoped() IRoleDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r roleDo) Create(values ...*models.Role) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r roleDo) CreateInBatches(values []*models.Role, batchSize int) error {
|
||||
return r.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 (r roleDo) Save(values ...*models.Role) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r roleDo) First() (*models.Role, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Role), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r roleDo) Take() (*models.Role, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Role), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r roleDo) Last() (*models.Role, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Role), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r roleDo) Find() ([]*models.Role, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.Role), err
|
||||
}
|
||||
|
||||
func (r roleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Role, err error) {
|
||||
buf := make([]*models.Role, 0, batchSize)
|
||||
err = r.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 (r roleDo) FindInBatches(result *[]*models.Role, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r roleDo) Attrs(attrs ...field.AssignExpr) IRoleDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r roleDo) Assign(attrs ...field.AssignExpr) IRoleDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r roleDo) Joins(fields ...field.RelationField) IRoleDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r roleDo) Preload(fields ...field.RelationField) IRoleDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r roleDo) FirstOrInit() (*models.Role, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Role), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r roleDo) FirstOrCreate() (*models.Role, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Role), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r roleDo) FindByPage(offset int, limit int) (result []*models.Role, count int64, err error) {
|
||||
result, err = r.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 = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r roleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r roleDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r roleDo) Delete(models ...*models.Role) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *roleDo) withDO(do gen.Dao) *roleDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
465
storage-new/dbgen/user_auth_methods.gen.go
Normal file
465
storage-new/dbgen/user_auth_methods.gen.go
Normal file
|
@ -0,0 +1,465 @@
|
|||
// 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 newUserAuthMethod(db *gorm.DB, opts ...gen.DOOption) userAuthMethod {
|
||||
_userAuthMethod := userAuthMethod{}
|
||||
|
||||
_userAuthMethod.userAuthMethodDo.UseDB(db, opts...)
|
||||
_userAuthMethod.userAuthMethodDo.UseModel(&models.UserAuthMethod{})
|
||||
|
||||
tableName := _userAuthMethod.userAuthMethodDo.TableName()
|
||||
_userAuthMethod.ALL = field.NewAsterisk(tableName)
|
||||
_userAuthMethod.UserId = field.NewString(tableName, "user_id")
|
||||
_userAuthMethod.AuthMethod = field.NewField(tableName, "auth_method")
|
||||
_userAuthMethod.Token = field.NewBytes(tableName, "token")
|
||||
_userAuthMethod.User = userAuthMethodBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userAuthMethod.fillFieldMap()
|
||||
|
||||
return _userAuthMethod
|
||||
}
|
||||
|
||||
type userAuthMethod struct {
|
||||
userAuthMethodDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
AuthMethod field.Field
|
||||
Token field.Bytes
|
||||
User userAuthMethodBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userAuthMethod) Table(newTableName string) *userAuthMethod {
|
||||
u.userAuthMethodDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userAuthMethod) As(alias string) *userAuthMethod {
|
||||
u.userAuthMethodDo.DO = *(u.userAuthMethodDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userAuthMethod) updateTableName(table string) *userAuthMethod {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.AuthMethod = field.NewField(table, "auth_method")
|
||||
u.Token = field.NewBytes(table, "token")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userAuthMethod) 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 *userAuthMethod) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 4)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["auth_method"] = u.AuthMethod
|
||||
u.fieldMap["token"] = u.Token
|
||||
|
||||
}
|
||||
|
||||
func (u userAuthMethod) clone(db *gorm.DB) userAuthMethod {
|
||||
u.userAuthMethodDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userAuthMethod) replaceDB(db *gorm.DB) userAuthMethod {
|
||||
u.userAuthMethodDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userAuthMethodBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Where(conds ...field.Expr) *userAuthMethodBelongsToUser {
|
||||
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 userAuthMethodBelongsToUser) WithContext(ctx context.Context) *userAuthMethodBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Session(session *gorm.Session) *userAuthMethodBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUser) Model(m *models.UserAuthMethod) *userAuthMethodBelongsToUserTx {
|
||||
return &userAuthMethodBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userAuthMethodBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) 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 userAuthMethodBelongsToUserTx) 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 userAuthMethodBelongsToUserTx) 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 userAuthMethodBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userAuthMethodBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userAuthMethodDo struct{ gen.DO }
|
||||
|
||||
type IUserAuthMethodDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserAuthMethodDo
|
||||
WithContext(ctx context.Context) IUserAuthMethodDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserAuthMethodDo
|
||||
WriteDB() IUserAuthMethodDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserAuthMethodDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserAuthMethodDo
|
||||
Not(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Or(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Select(conds ...field.Expr) IUserAuthMethodDo
|
||||
Where(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Order(conds ...field.Expr) IUserAuthMethodDo
|
||||
Distinct(cols ...field.Expr) IUserAuthMethodDo
|
||||
Omit(cols ...field.Expr) IUserAuthMethodDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo
|
||||
Group(cols ...field.Expr) IUserAuthMethodDo
|
||||
Having(conds ...gen.Condition) IUserAuthMethodDo
|
||||
Limit(limit int) IUserAuthMethodDo
|
||||
Offset(offset int) IUserAuthMethodDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserAuthMethodDo
|
||||
Unscoped() IUserAuthMethodDo
|
||||
Create(values ...*models.UserAuthMethod) error
|
||||
CreateInBatches(values []*models.UserAuthMethod, batchSize int) error
|
||||
Save(values ...*models.UserAuthMethod) error
|
||||
First() (*models.UserAuthMethod, error)
|
||||
Take() (*models.UserAuthMethod, error)
|
||||
Last() (*models.UserAuthMethod, error)
|
||||
Find() ([]*models.UserAuthMethod, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserAuthMethod, err error)
|
||||
FindInBatches(result *[]*models.UserAuthMethod, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserAuthMethod) (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) IUserAuthMethodDo
|
||||
Assign(attrs ...field.AssignExpr) IUserAuthMethodDo
|
||||
Joins(fields ...field.RelationField) IUserAuthMethodDo
|
||||
Preload(fields ...field.RelationField) IUserAuthMethodDo
|
||||
FirstOrInit() (*models.UserAuthMethod, error)
|
||||
FirstOrCreate() (*models.UserAuthMethod, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserAuthMethod, 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) IUserAuthMethodDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Debug() IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) WithContext(ctx context.Context) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) ReadDB() IUserAuthMethodDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) WriteDB() IUserAuthMethodDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Session(config *gorm.Session) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Clauses(conds ...clause.Expression) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Returning(value interface{}, columns ...string) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Not(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Or(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Select(conds ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Where(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Order(conds ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Distinct(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Omit(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Join(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Group(cols ...field.Expr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Having(conds ...gen.Condition) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Limit(limit int) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Offset(offset int) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Unscoped() IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Create(values ...*models.UserAuthMethod) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) CreateInBatches(values []*models.UserAuthMethod, 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 userAuthMethodDo) Save(values ...*models.UserAuthMethod) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) First() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Take() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Last() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Find() ([]*models.UserAuthMethod, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserAuthMethod), err
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserAuthMethod, err error) {
|
||||
buf := make([]*models.UserAuthMethod, 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 userAuthMethodDo) FindInBatches(result *[]*models.UserAuthMethod, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Attrs(attrs ...field.AssignExpr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Assign(attrs ...field.AssignExpr) IUserAuthMethodDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Joins(fields ...field.RelationField) IUserAuthMethodDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Preload(fields ...field.RelationField) IUserAuthMethodDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FirstOrInit() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FirstOrCreate() (*models.UserAuthMethod, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserAuthMethod), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) FindByPage(offset int, limit int) (result []*models.UserAuthMethod, 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 userAuthMethodDo) 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 userAuthMethodDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userAuthMethodDo) Delete(models ...*models.UserAuthMethod) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userAuthMethodDo) withDO(do gen.Dao) *userAuthMethodDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
489
storage-new/dbgen/user_info_fields.gen.go
Normal file
489
storage-new/dbgen/user_info_fields.gen.go
Normal file
|
@ -0,0 +1,489 @@
|
|||
// 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 newUserInfoField(db *gorm.DB, opts ...gen.DOOption) userInfoField {
|
||||
_userInfoField := userInfoField{}
|
||||
|
||||
_userInfoField.userInfoFieldDo.UseDB(db, opts...)
|
||||
_userInfoField.userInfoFieldDo.UseModel(&models.UserInfoField{})
|
||||
|
||||
tableName := _userInfoField.userInfoFieldDo.TableName()
|
||||
_userInfoField.ALL = field.NewAsterisk(tableName)
|
||||
_userInfoField.ID = field.NewUint(tableName, "id")
|
||||
_userInfoField.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userInfoField.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userInfoField.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_userInfoField.Name = field.NewString(tableName, "name")
|
||||
_userInfoField.Value = field.NewString(tableName, "value")
|
||||
_userInfoField.LastUrlCheckDate = field.NewTime(tableName, "last_url_check_date")
|
||||
_userInfoField.Confirmed = field.NewBool(tableName, "confirmed")
|
||||
_userInfoField.UserId = field.NewString(tableName, "user_id")
|
||||
_userInfoField.User = userInfoFieldBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userInfoField.fillFieldMap()
|
||||
|
||||
return _userInfoField
|
||||
}
|
||||
|
||||
type userInfoField struct {
|
||||
userInfoFieldDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
Name field.String
|
||||
Value field.String
|
||||
LastUrlCheckDate field.Time
|
||||
Confirmed field.Bool
|
||||
UserId field.String
|
||||
User userInfoFieldBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userInfoField) Table(newTableName string) *userInfoField {
|
||||
u.userInfoFieldDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userInfoField) As(alias string) *userInfoField {
|
||||
u.userInfoFieldDo.DO = *(u.userInfoFieldDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userInfoField) updateTableName(table string) *userInfoField {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewUint(table, "id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
u.Name = field.NewString(table, "name")
|
||||
u.Value = field.NewString(table, "value")
|
||||
u.LastUrlCheckDate = field.NewTime(table, "last_url_check_date")
|
||||
u.Confirmed = field.NewBool(table, "confirmed")
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userInfoField) 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 *userInfoField) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 10)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
u.fieldMap["name"] = u.Name
|
||||
u.fieldMap["value"] = u.Value
|
||||
u.fieldMap["last_url_check_date"] = u.LastUrlCheckDate
|
||||
u.fieldMap["confirmed"] = u.Confirmed
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
|
||||
}
|
||||
|
||||
func (u userInfoField) clone(db *gorm.DB) userInfoField {
|
||||
u.userInfoFieldDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userInfoField) replaceDB(db *gorm.DB) userInfoField {
|
||||
u.userInfoFieldDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userInfoFieldBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userInfoFieldBelongsToUser) Where(conds ...field.Expr) *userInfoFieldBelongsToUser {
|
||||
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 userInfoFieldBelongsToUser) WithContext(ctx context.Context) *userInfoFieldBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userInfoFieldBelongsToUser) Session(session *gorm.Session) *userInfoFieldBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userInfoFieldBelongsToUser) Model(m *models.UserInfoField) *userInfoFieldBelongsToUserTx {
|
||||
return &userInfoFieldBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userInfoFieldBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userInfoFieldBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userInfoFieldBelongsToUserTx) 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 userInfoFieldBelongsToUserTx) 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 userInfoFieldBelongsToUserTx) 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 userInfoFieldBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userInfoFieldBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userInfoFieldDo struct{ gen.DO }
|
||||
|
||||
type IUserInfoFieldDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserInfoFieldDo
|
||||
WithContext(ctx context.Context) IUserInfoFieldDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserInfoFieldDo
|
||||
WriteDB() IUserInfoFieldDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserInfoFieldDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserInfoFieldDo
|
||||
Not(conds ...gen.Condition) IUserInfoFieldDo
|
||||
Or(conds ...gen.Condition) IUserInfoFieldDo
|
||||
Select(conds ...field.Expr) IUserInfoFieldDo
|
||||
Where(conds ...gen.Condition) IUserInfoFieldDo
|
||||
Order(conds ...field.Expr) IUserInfoFieldDo
|
||||
Distinct(cols ...field.Expr) IUserInfoFieldDo
|
||||
Omit(cols ...field.Expr) IUserInfoFieldDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo
|
||||
Group(cols ...field.Expr) IUserInfoFieldDo
|
||||
Having(conds ...gen.Condition) IUserInfoFieldDo
|
||||
Limit(limit int) IUserInfoFieldDo
|
||||
Offset(offset int) IUserInfoFieldDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserInfoFieldDo
|
||||
Unscoped() IUserInfoFieldDo
|
||||
Create(values ...*models.UserInfoField) error
|
||||
CreateInBatches(values []*models.UserInfoField, batchSize int) error
|
||||
Save(values ...*models.UserInfoField) error
|
||||
First() (*models.UserInfoField, error)
|
||||
Take() (*models.UserInfoField, error)
|
||||
Last() (*models.UserInfoField, error)
|
||||
Find() ([]*models.UserInfoField, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserInfoField, err error)
|
||||
FindInBatches(result *[]*models.UserInfoField, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserInfoField) (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) IUserInfoFieldDo
|
||||
Assign(attrs ...field.AssignExpr) IUserInfoFieldDo
|
||||
Joins(fields ...field.RelationField) IUserInfoFieldDo
|
||||
Preload(fields ...field.RelationField) IUserInfoFieldDo
|
||||
FirstOrInit() (*models.UserInfoField, error)
|
||||
FirstOrCreate() (*models.UserInfoField, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserInfoField, 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) IUserInfoFieldDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Debug() IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) WithContext(ctx context.Context) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) ReadDB() IUserInfoFieldDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) WriteDB() IUserInfoFieldDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Session(config *gorm.Session) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Clauses(conds ...clause.Expression) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Returning(value interface{}, columns ...string) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Not(conds ...gen.Condition) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Or(conds ...gen.Condition) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Select(conds ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Where(conds ...gen.Condition) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Order(conds ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Distinct(cols ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Omit(cols ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Join(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Group(cols ...field.Expr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Having(conds ...gen.Condition) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Limit(limit int) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Offset(offset int) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Unscoped() IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Create(values ...*models.UserInfoField) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) CreateInBatches(values []*models.UserInfoField, 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 userInfoFieldDo) Save(values ...*models.UserInfoField) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) First() (*models.UserInfoField, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserInfoField), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Take() (*models.UserInfoField, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserInfoField), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Last() (*models.UserInfoField, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserInfoField), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Find() ([]*models.UserInfoField, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserInfoField), err
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserInfoField, err error) {
|
||||
buf := make([]*models.UserInfoField, 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 userInfoFieldDo) FindInBatches(result *[]*models.UserInfoField, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Attrs(attrs ...field.AssignExpr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Assign(attrs ...field.AssignExpr) IUserInfoFieldDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Joins(fields ...field.RelationField) IUserInfoFieldDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Preload(fields ...field.RelationField) IUserInfoFieldDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) FirstOrInit() (*models.UserInfoField, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserInfoField), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) FirstOrCreate() (*models.UserInfoField, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserInfoField), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) FindByPage(offset int, limit int) (result []*models.UserInfoField, 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 userInfoFieldDo) 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 userInfoFieldDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userInfoFieldDo) Delete(models ...*models.UserInfoField) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userInfoFieldDo) withDO(do gen.Dao) *userInfoFieldDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
505
storage-new/dbgen/user_remote_links.gen.go
Normal file
505
storage-new/dbgen/user_remote_links.gen.go
Normal file
|
@ -0,0 +1,505 @@
|
|||
// 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 newUserRemoteLinks(db *gorm.DB, opts ...gen.DOOption) userRemoteLinks {
|
||||
_userRemoteLinks := userRemoteLinks{}
|
||||
|
||||
_userRemoteLinks.userRemoteLinksDo.UseDB(db, opts...)
|
||||
_userRemoteLinks.userRemoteLinksDo.UseModel(&models.UserRemoteLinks{})
|
||||
|
||||
tableName := _userRemoteLinks.userRemoteLinksDo.TableName()
|
||||
_userRemoteLinks.ALL = field.NewAsterisk(tableName)
|
||||
_userRemoteLinks.ID = field.NewUint(tableName, "id")
|
||||
_userRemoteLinks.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userRemoteLinks.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userRemoteLinks.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_userRemoteLinks.UserId = field.NewString(tableName, "user_id")
|
||||
_userRemoteLinks.ApLink = field.NewString(tableName, "ap_link")
|
||||
_userRemoteLinks.ViewLink = field.NewString(tableName, "view_link")
|
||||
_userRemoteLinks.FollowersLink = field.NewString(tableName, "followers_link")
|
||||
_userRemoteLinks.FollowingLink = field.NewString(tableName, "following_link")
|
||||
_userRemoteLinks.InboxLink = field.NewString(tableName, "inbox_link")
|
||||
_userRemoteLinks.OutboxLink = field.NewString(tableName, "outbox_link")
|
||||
_userRemoteLinks.FeaturedLink = field.NewString(tableName, "featured_link")
|
||||
_userRemoteLinks.FeaturedTagsLink = field.NewString(tableName, "featured_tags_link")
|
||||
_userRemoteLinks.User = userRemoteLinksBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userRemoteLinks.fillFieldMap()
|
||||
|
||||
return _userRemoteLinks
|
||||
}
|
||||
|
||||
type userRemoteLinks struct {
|
||||
userRemoteLinksDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Uint
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
UserId field.String
|
||||
ApLink field.String
|
||||
ViewLink field.String
|
||||
FollowersLink field.String
|
||||
FollowingLink field.String
|
||||
InboxLink field.String
|
||||
OutboxLink field.String
|
||||
FeaturedLink field.String
|
||||
FeaturedTagsLink field.String
|
||||
User userRemoteLinksBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userRemoteLinks) Table(newTableName string) *userRemoteLinks {
|
||||
u.userRemoteLinksDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userRemoteLinks) As(alias string) *userRemoteLinks {
|
||||
u.userRemoteLinksDo.DO = *(u.userRemoteLinksDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userRemoteLinks) updateTableName(table string) *userRemoteLinks {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewUint(table, "id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.ApLink = field.NewString(table, "ap_link")
|
||||
u.ViewLink = field.NewString(table, "view_link")
|
||||
u.FollowersLink = field.NewString(table, "followers_link")
|
||||
u.FollowingLink = field.NewString(table, "following_link")
|
||||
u.InboxLink = field.NewString(table, "inbox_link")
|
||||
u.OutboxLink = field.NewString(table, "outbox_link")
|
||||
u.FeaturedLink = field.NewString(table, "featured_link")
|
||||
u.FeaturedTagsLink = field.NewString(table, "featured_tags_link")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userRemoteLinks) 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 *userRemoteLinks) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 14)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["ap_link"] = u.ApLink
|
||||
u.fieldMap["view_link"] = u.ViewLink
|
||||
u.fieldMap["followers_link"] = u.FollowersLink
|
||||
u.fieldMap["following_link"] = u.FollowingLink
|
||||
u.fieldMap["inbox_link"] = u.InboxLink
|
||||
u.fieldMap["outbox_link"] = u.OutboxLink
|
||||
u.fieldMap["featured_link"] = u.FeaturedLink
|
||||
u.fieldMap["featured_tags_link"] = u.FeaturedTagsLink
|
||||
|
||||
}
|
||||
|
||||
func (u userRemoteLinks) clone(db *gorm.DB) userRemoteLinks {
|
||||
u.userRemoteLinksDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userRemoteLinks) replaceDB(db *gorm.DB) userRemoteLinks {
|
||||
u.userRemoteLinksDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userRemoteLinksBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userRemoteLinksBelongsToUser) Where(conds ...field.Expr) *userRemoteLinksBelongsToUser {
|
||||
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 userRemoteLinksBelongsToUser) WithContext(ctx context.Context) *userRemoteLinksBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userRemoteLinksBelongsToUser) Session(session *gorm.Session) *userRemoteLinksBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userRemoteLinksBelongsToUser) Model(m *models.UserRemoteLinks) *userRemoteLinksBelongsToUserTx {
|
||||
return &userRemoteLinksBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userRemoteLinksBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userRemoteLinksBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userRemoteLinksBelongsToUserTx) 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 userRemoteLinksBelongsToUserTx) 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 userRemoteLinksBelongsToUserTx) 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 userRemoteLinksBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userRemoteLinksBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userRemoteLinksDo struct{ gen.DO }
|
||||
|
||||
type IUserRemoteLinksDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserRemoteLinksDo
|
||||
WithContext(ctx context.Context) IUserRemoteLinksDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserRemoteLinksDo
|
||||
WriteDB() IUserRemoteLinksDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserRemoteLinksDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserRemoteLinksDo
|
||||
Not(conds ...gen.Condition) IUserRemoteLinksDo
|
||||
Or(conds ...gen.Condition) IUserRemoteLinksDo
|
||||
Select(conds ...field.Expr) IUserRemoteLinksDo
|
||||
Where(conds ...gen.Condition) IUserRemoteLinksDo
|
||||
Order(conds ...field.Expr) IUserRemoteLinksDo
|
||||
Distinct(cols ...field.Expr) IUserRemoteLinksDo
|
||||
Omit(cols ...field.Expr) IUserRemoteLinksDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo
|
||||
Group(cols ...field.Expr) IUserRemoteLinksDo
|
||||
Having(conds ...gen.Condition) IUserRemoteLinksDo
|
||||
Limit(limit int) IUserRemoteLinksDo
|
||||
Offset(offset int) IUserRemoteLinksDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserRemoteLinksDo
|
||||
Unscoped() IUserRemoteLinksDo
|
||||
Create(values ...*models.UserRemoteLinks) error
|
||||
CreateInBatches(values []*models.UserRemoteLinks, batchSize int) error
|
||||
Save(values ...*models.UserRemoteLinks) error
|
||||
First() (*models.UserRemoteLinks, error)
|
||||
Take() (*models.UserRemoteLinks, error)
|
||||
Last() (*models.UserRemoteLinks, error)
|
||||
Find() ([]*models.UserRemoteLinks, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRemoteLinks, err error)
|
||||
FindInBatches(result *[]*models.UserRemoteLinks, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserRemoteLinks) (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) IUserRemoteLinksDo
|
||||
Assign(attrs ...field.AssignExpr) IUserRemoteLinksDo
|
||||
Joins(fields ...field.RelationField) IUserRemoteLinksDo
|
||||
Preload(fields ...field.RelationField) IUserRemoteLinksDo
|
||||
FirstOrInit() (*models.UserRemoteLinks, error)
|
||||
FirstOrCreate() (*models.UserRemoteLinks, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserRemoteLinks, 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) IUserRemoteLinksDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Debug() IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) WithContext(ctx context.Context) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) ReadDB() IUserRemoteLinksDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) WriteDB() IUserRemoteLinksDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Session(config *gorm.Session) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Clauses(conds ...clause.Expression) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Returning(value interface{}, columns ...string) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Not(conds ...gen.Condition) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Or(conds ...gen.Condition) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Select(conds ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Where(conds ...gen.Condition) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Order(conds ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Distinct(cols ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Omit(cols ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Join(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Group(cols ...field.Expr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Having(conds ...gen.Condition) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Limit(limit int) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Offset(offset int) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Unscoped() IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Create(values ...*models.UserRemoteLinks) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) CreateInBatches(values []*models.UserRemoteLinks, 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 userRemoteLinksDo) Save(values ...*models.UserRemoteLinks) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) First() (*models.UserRemoteLinks, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRemoteLinks), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Take() (*models.UserRemoteLinks, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRemoteLinks), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Last() (*models.UserRemoteLinks, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRemoteLinks), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Find() ([]*models.UserRemoteLinks, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserRemoteLinks), err
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRemoteLinks, err error) {
|
||||
buf := make([]*models.UserRemoteLinks, 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 userRemoteLinksDo) FindInBatches(result *[]*models.UserRemoteLinks, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Attrs(attrs ...field.AssignExpr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Assign(attrs ...field.AssignExpr) IUserRemoteLinksDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Joins(fields ...field.RelationField) IUserRemoteLinksDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Preload(fields ...field.RelationField) IUserRemoteLinksDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) FirstOrInit() (*models.UserRemoteLinks, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRemoteLinks), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) FirstOrCreate() (*models.UserRemoteLinks, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRemoteLinks), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) FindByPage(offset int, limit int) (result []*models.UserRemoteLinks, 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 userRemoteLinksDo) 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 userRemoteLinksDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userRemoteLinksDo) Delete(models ...*models.UserRemoteLinks) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userRemoteLinksDo) withDO(do gen.Dao) *userRemoteLinksDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
461
storage-new/dbgen/user_to_beings.gen.go
Normal file
461
storage-new/dbgen/user_to_beings.gen.go
Normal file
|
@ -0,0 +1,461 @@
|
|||
// 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 newUserToBeing(db *gorm.DB, opts ...gen.DOOption) userToBeing {
|
||||
_userToBeing := userToBeing{}
|
||||
|
||||
_userToBeing.userToBeingDo.UseDB(db, opts...)
|
||||
_userToBeing.userToBeingDo.UseModel(&models.UserToBeing{})
|
||||
|
||||
tableName := _userToBeing.userToBeingDo.TableName()
|
||||
_userToBeing.ALL = field.NewAsterisk(tableName)
|
||||
_userToBeing.UserId = field.NewString(tableName, "user_id")
|
||||
_userToBeing.Being = field.NewField(tableName, "being")
|
||||
_userToBeing.User = userToBeingBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userToBeing.fillFieldMap()
|
||||
|
||||
return _userToBeing
|
||||
}
|
||||
|
||||
type userToBeing struct {
|
||||
userToBeingDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
Being field.Field
|
||||
User userToBeingBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userToBeing) Table(newTableName string) *userToBeing {
|
||||
u.userToBeingDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userToBeing) As(alias string) *userToBeing {
|
||||
u.userToBeingDo.DO = *(u.userToBeingDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userToBeing) updateTableName(table string) *userToBeing {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.Being = field.NewField(table, "being")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userToBeing) 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 *userToBeing) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 3)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["being"] = u.Being
|
||||
|
||||
}
|
||||
|
||||
func (u userToBeing) clone(db *gorm.DB) userToBeing {
|
||||
u.userToBeingDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToBeing) replaceDB(db *gorm.DB) userToBeing {
|
||||
u.userToBeingDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userToBeingBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToBeingBelongsToUser) Where(conds ...field.Expr) *userToBeingBelongsToUser {
|
||||
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 userToBeingBelongsToUser) WithContext(ctx context.Context) *userToBeingBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToBeingBelongsToUser) Session(session *gorm.Session) *userToBeingBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToBeingBelongsToUser) Model(m *models.UserToBeing) *userToBeingBelongsToUserTx {
|
||||
return &userToBeingBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToBeingBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToBeingBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToBeingBelongsToUserTx) 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 userToBeingBelongsToUserTx) 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 userToBeingBelongsToUserTx) 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 userToBeingBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToBeingBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToBeingDo struct{ gen.DO }
|
||||
|
||||
type IUserToBeingDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserToBeingDo
|
||||
WithContext(ctx context.Context) IUserToBeingDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserToBeingDo
|
||||
WriteDB() IUserToBeingDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserToBeingDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserToBeingDo
|
||||
Not(conds ...gen.Condition) IUserToBeingDo
|
||||
Or(conds ...gen.Condition) IUserToBeingDo
|
||||
Select(conds ...field.Expr) IUserToBeingDo
|
||||
Where(conds ...gen.Condition) IUserToBeingDo
|
||||
Order(conds ...field.Expr) IUserToBeingDo
|
||||
Distinct(cols ...field.Expr) IUserToBeingDo
|
||||
Omit(cols ...field.Expr) IUserToBeingDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserToBeingDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserToBeingDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserToBeingDo
|
||||
Group(cols ...field.Expr) IUserToBeingDo
|
||||
Having(conds ...gen.Condition) IUserToBeingDo
|
||||
Limit(limit int) IUserToBeingDo
|
||||
Offset(offset int) IUserToBeingDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToBeingDo
|
||||
Unscoped() IUserToBeingDo
|
||||
Create(values ...*models.UserToBeing) error
|
||||
CreateInBatches(values []*models.UserToBeing, batchSize int) error
|
||||
Save(values ...*models.UserToBeing) error
|
||||
First() (*models.UserToBeing, error)
|
||||
Take() (*models.UserToBeing, error)
|
||||
Last() (*models.UserToBeing, error)
|
||||
Find() ([]*models.UserToBeing, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToBeing, err error)
|
||||
FindInBatches(result *[]*models.UserToBeing, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserToBeing) (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) IUserToBeingDo
|
||||
Assign(attrs ...field.AssignExpr) IUserToBeingDo
|
||||
Joins(fields ...field.RelationField) IUserToBeingDo
|
||||
Preload(fields ...field.RelationField) IUserToBeingDo
|
||||
FirstOrInit() (*models.UserToBeing, error)
|
||||
FirstOrCreate() (*models.UserToBeing, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToBeing, 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) IUserToBeingDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Debug() IUserToBeingDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userToBeingDo) WithContext(ctx context.Context) IUserToBeingDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) ReadDB() IUserToBeingDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) WriteDB() IUserToBeingDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Session(config *gorm.Session) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Clauses(conds ...clause.Expression) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Returning(value interface{}, columns ...string) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Not(conds ...gen.Condition) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Or(conds ...gen.Condition) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Select(conds ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Where(conds ...gen.Condition) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Order(conds ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Distinct(cols ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Omit(cols ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Join(table schema.Tabler, on ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Group(cols ...field.Expr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Having(conds ...gen.Condition) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Limit(limit int) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Offset(offset int) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Unscoped() IUserToBeingDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Create(values ...*models.UserToBeing) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) CreateInBatches(values []*models.UserToBeing, 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 userToBeingDo) Save(values ...*models.UserToBeing) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) First() (*models.UserToBeing, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToBeing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Take() (*models.UserToBeing, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToBeing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Last() (*models.UserToBeing, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToBeing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Find() ([]*models.UserToBeing, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserToBeing), err
|
||||
}
|
||||
|
||||
func (u userToBeingDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToBeing, err error) {
|
||||
buf := make([]*models.UserToBeing, 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 userToBeingDo) FindInBatches(result *[]*models.UserToBeing, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Attrs(attrs ...field.AssignExpr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Assign(attrs ...field.AssignExpr) IUserToBeingDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Joins(fields ...field.RelationField) IUserToBeingDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Preload(fields ...field.RelationField) IUserToBeingDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToBeingDo) FirstOrInit() (*models.UserToBeing, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToBeing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToBeingDo) FirstOrCreate() (*models.UserToBeing, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToBeing), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToBeingDo) FindByPage(offset int, limit int) (result []*models.UserToBeing, 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 userToBeingDo) 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 userToBeingDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userToBeingDo) Delete(models ...*models.UserToBeing) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userToBeingDo) withDO(do gen.Dao) *userToBeingDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
540
storage-new/dbgen/user_to_roles.gen.go
Normal file
540
storage-new/dbgen/user_to_roles.gen.go
Normal file
|
@ -0,0 +1,540 @@
|
|||
// 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 newUserToRole(db *gorm.DB, opts ...gen.DOOption) userToRole {
|
||||
_userToRole := userToRole{}
|
||||
|
||||
_userToRole.userToRoleDo.UseDB(db, opts...)
|
||||
_userToRole.userToRoleDo.UseModel(&models.UserToRole{})
|
||||
|
||||
tableName := _userToRole.userToRoleDo.TableName()
|
||||
_userToRole.ALL = field.NewAsterisk(tableName)
|
||||
_userToRole.UserId = field.NewString(tableName, "user_id")
|
||||
_userToRole.RoleId = field.NewUint(tableName, "role_id")
|
||||
_userToRole.User = userToRoleBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userToRole.Role = userToRoleBelongsToRole{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Role", "models.Role"),
|
||||
}
|
||||
|
||||
_userToRole.fillFieldMap()
|
||||
|
||||
return _userToRole
|
||||
}
|
||||
|
||||
type userToRole struct {
|
||||
userToRoleDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
RoleId field.Uint
|
||||
User userToRoleBelongsToUser
|
||||
|
||||
Role userToRoleBelongsToRole
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userToRole) Table(newTableName string) *userToRole {
|
||||
u.userToRoleDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userToRole) As(alias string) *userToRole {
|
||||
u.userToRoleDo.DO = *(u.userToRoleDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userToRole) updateTableName(table string) *userToRole {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.RoleId = field.NewUint(table, "role_id")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userToRole) 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 *userToRole) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 4)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["role_id"] = u.RoleId
|
||||
|
||||
}
|
||||
|
||||
func (u userToRole) clone(db *gorm.DB) userToRole {
|
||||
u.userToRoleDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToRole) replaceDB(db *gorm.DB) userToRole {
|
||||
u.userToRoleDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userToRoleBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUser) Where(conds ...field.Expr) *userToRoleBelongsToUser {
|
||||
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 userToRoleBelongsToUser) WithContext(ctx context.Context) *userToRoleBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUser) Session(session *gorm.Session) *userToRoleBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUser) Model(m *models.UserToRole) *userToRoleBelongsToUserTx {
|
||||
return &userToRoleBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToRoleBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToRoleBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUserTx) 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 userToRoleBelongsToUserTx) 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 userToRoleBelongsToUserTx) 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 userToRoleBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToRoleBelongsToRole struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRole) Where(conds ...field.Expr) *userToRoleBelongsToRole {
|
||||
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 userToRoleBelongsToRole) WithContext(ctx context.Context) *userToRoleBelongsToRole {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRole) Session(session *gorm.Session) *userToRoleBelongsToRole {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRole) Model(m *models.UserToRole) *userToRoleBelongsToRoleTx {
|
||||
return &userToRoleBelongsToRoleTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToRoleBelongsToRoleTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Find() (result *models.Role, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Append(values ...*models.Role) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Replace(values ...*models.Role) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Delete(values ...*models.Role) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToRoleBelongsToRoleTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToRoleDo struct{ gen.DO }
|
||||
|
||||
type IUserToRoleDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserToRoleDo
|
||||
WithContext(ctx context.Context) IUserToRoleDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserToRoleDo
|
||||
WriteDB() IUserToRoleDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserToRoleDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserToRoleDo
|
||||
Not(conds ...gen.Condition) IUserToRoleDo
|
||||
Or(conds ...gen.Condition) IUserToRoleDo
|
||||
Select(conds ...field.Expr) IUserToRoleDo
|
||||
Where(conds ...gen.Condition) IUserToRoleDo
|
||||
Order(conds ...field.Expr) IUserToRoleDo
|
||||
Distinct(cols ...field.Expr) IUserToRoleDo
|
||||
Omit(cols ...field.Expr) IUserToRoleDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserToRoleDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserToRoleDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserToRoleDo
|
||||
Group(cols ...field.Expr) IUserToRoleDo
|
||||
Having(conds ...gen.Condition) IUserToRoleDo
|
||||
Limit(limit int) IUserToRoleDo
|
||||
Offset(offset int) IUserToRoleDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToRoleDo
|
||||
Unscoped() IUserToRoleDo
|
||||
Create(values ...*models.UserToRole) error
|
||||
CreateInBatches(values []*models.UserToRole, batchSize int) error
|
||||
Save(values ...*models.UserToRole) error
|
||||
First() (*models.UserToRole, error)
|
||||
Take() (*models.UserToRole, error)
|
||||
Last() (*models.UserToRole, error)
|
||||
Find() ([]*models.UserToRole, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToRole, err error)
|
||||
FindInBatches(result *[]*models.UserToRole, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserToRole) (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) IUserToRoleDo
|
||||
Assign(attrs ...field.AssignExpr) IUserToRoleDo
|
||||
Joins(fields ...field.RelationField) IUserToRoleDo
|
||||
Preload(fields ...field.RelationField) IUserToRoleDo
|
||||
FirstOrInit() (*models.UserToRole, error)
|
||||
FirstOrCreate() (*models.UserToRole, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToRole, 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) IUserToRoleDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Debug() IUserToRoleDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userToRoleDo) WithContext(ctx context.Context) IUserToRoleDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) ReadDB() IUserToRoleDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) WriteDB() IUserToRoleDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Session(config *gorm.Session) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Clauses(conds ...clause.Expression) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Returning(value interface{}, columns ...string) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Not(conds ...gen.Condition) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Or(conds ...gen.Condition) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Select(conds ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Where(conds ...gen.Condition) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Order(conds ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Distinct(cols ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Omit(cols ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Join(table schema.Tabler, on ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Group(cols ...field.Expr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Having(conds ...gen.Condition) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Limit(limit int) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Offset(offset int) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Unscoped() IUserToRoleDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Create(values ...*models.UserToRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) CreateInBatches(values []*models.UserToRole, 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 userToRoleDo) Save(values ...*models.UserToRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) First() (*models.UserToRole, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Take() (*models.UserToRole, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Last() (*models.UserToRole, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Find() ([]*models.UserToRole, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserToRole), err
|
||||
}
|
||||
|
||||
func (u userToRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToRole, err error) {
|
||||
buf := make([]*models.UserToRole, 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 userToRoleDo) FindInBatches(result *[]*models.UserToRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Attrs(attrs ...field.AssignExpr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Assign(attrs ...field.AssignExpr) IUserToRoleDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Joins(fields ...field.RelationField) IUserToRoleDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Preload(fields ...field.RelationField) IUserToRoleDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToRoleDo) FirstOrInit() (*models.UserToRole, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToRoleDo) FirstOrCreate() (*models.UserToRole, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToRoleDo) FindByPage(offset int, limit int) (result []*models.UserToRole, 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 userToRoleDo) 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 userToRoleDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userToRoleDo) Delete(models ...*models.UserToRole) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userToRoleDo) withDO(do gen.Dao) *userToRoleDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
461
storage-new/dbgen/user_to_tags.gen.go
Normal file
461
storage-new/dbgen/user_to_tags.gen.go
Normal file
|
@ -0,0 +1,461 @@
|
|||
// 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 newUserToTag(db *gorm.DB, opts ...gen.DOOption) userToTag {
|
||||
_userToTag := userToTag{}
|
||||
|
||||
_userToTag.userToTagDo.UseDB(db, opts...)
|
||||
_userToTag.userToTagDo.UseModel(&models.UserToTag{})
|
||||
|
||||
tableName := _userToTag.userToTagDo.TableName()
|
||||
_userToTag.ALL = field.NewAsterisk(tableName)
|
||||
_userToTag.UserId = field.NewString(tableName, "user_id")
|
||||
_userToTag.Tag = field.NewString(tableName, "tag")
|
||||
_userToTag.User = userToTagBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userToTag.fillFieldMap()
|
||||
|
||||
return _userToTag
|
||||
}
|
||||
|
||||
type userToTag struct {
|
||||
userToTagDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
Tag field.String
|
||||
User userToTagBelongsToUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userToTag) Table(newTableName string) *userToTag {
|
||||
u.userToTagDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userToTag) As(alias string) *userToTag {
|
||||
u.userToTagDo.DO = *(u.userToTagDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userToTag) updateTableName(table string) *userToTag {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.Tag = field.NewString(table, "tag")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userToTag) 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 *userToTag) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 3)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["tag"] = u.Tag
|
||||
|
||||
}
|
||||
|
||||
func (u userToTag) clone(db *gorm.DB) userToTag {
|
||||
u.userToTagDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToTag) replaceDB(db *gorm.DB) userToTag {
|
||||
u.userToTagDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userToTagBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToTagBelongsToUser) Where(conds ...field.Expr) *userToTagBelongsToUser {
|
||||
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 userToTagBelongsToUser) WithContext(ctx context.Context) *userToTagBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToTagBelongsToUser) Session(session *gorm.Session) *userToTagBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToTagBelongsToUser) Model(m *models.UserToTag) *userToTagBelongsToUserTx {
|
||||
return &userToTagBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToTagBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToTagBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToTagBelongsToUserTx) 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 userToTagBelongsToUserTx) 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 userToTagBelongsToUserTx) 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 userToTagBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToTagBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToTagDo struct{ gen.DO }
|
||||
|
||||
type IUserToTagDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserToTagDo
|
||||
WithContext(ctx context.Context) IUserToTagDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserToTagDo
|
||||
WriteDB() IUserToTagDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserToTagDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserToTagDo
|
||||
Not(conds ...gen.Condition) IUserToTagDo
|
||||
Or(conds ...gen.Condition) IUserToTagDo
|
||||
Select(conds ...field.Expr) IUserToTagDo
|
||||
Where(conds ...gen.Condition) IUserToTagDo
|
||||
Order(conds ...field.Expr) IUserToTagDo
|
||||
Distinct(cols ...field.Expr) IUserToTagDo
|
||||
Omit(cols ...field.Expr) IUserToTagDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserToTagDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserToTagDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserToTagDo
|
||||
Group(cols ...field.Expr) IUserToTagDo
|
||||
Having(conds ...gen.Condition) IUserToTagDo
|
||||
Limit(limit int) IUserToTagDo
|
||||
Offset(offset int) IUserToTagDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToTagDo
|
||||
Unscoped() IUserToTagDo
|
||||
Create(values ...*models.UserToTag) error
|
||||
CreateInBatches(values []*models.UserToTag, batchSize int) error
|
||||
Save(values ...*models.UserToTag) error
|
||||
First() (*models.UserToTag, error)
|
||||
Take() (*models.UserToTag, error)
|
||||
Last() (*models.UserToTag, error)
|
||||
Find() ([]*models.UserToTag, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToTag, err error)
|
||||
FindInBatches(result *[]*models.UserToTag, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserToTag) (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) IUserToTagDo
|
||||
Assign(attrs ...field.AssignExpr) IUserToTagDo
|
||||
Joins(fields ...field.RelationField) IUserToTagDo
|
||||
Preload(fields ...field.RelationField) IUserToTagDo
|
||||
FirstOrInit() (*models.UserToTag, error)
|
||||
FirstOrCreate() (*models.UserToTag, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToTag, 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) IUserToTagDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userToTagDo) Debug() IUserToTagDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userToTagDo) WithContext(ctx context.Context) IUserToTagDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userToTagDo) ReadDB() IUserToTagDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userToTagDo) WriteDB() IUserToTagDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userToTagDo) Session(config *gorm.Session) IUserToTagDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Clauses(conds ...clause.Expression) IUserToTagDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Returning(value interface{}, columns ...string) IUserToTagDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Not(conds ...gen.Condition) IUserToTagDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Or(conds ...gen.Condition) IUserToTagDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Select(conds ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Where(conds ...gen.Condition) IUserToTagDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Order(conds ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Distinct(cols ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Omit(cols ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Join(table schema.Tabler, on ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Group(cols ...field.Expr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Having(conds ...gen.Condition) IUserToTagDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Limit(limit int) IUserToTagDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Offset(offset int) IUserToTagDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToTagDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Unscoped() IUserToTagDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userToTagDo) Create(values ...*models.UserToTag) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userToTagDo) CreateInBatches(values []*models.UserToTag, 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 userToTagDo) Save(values ...*models.UserToTag) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userToTagDo) First() (*models.UserToTag, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToTagDo) Take() (*models.UserToTag, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToTagDo) Last() (*models.UserToTag, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToTagDo) Find() ([]*models.UserToTag, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserToTag), err
|
||||
}
|
||||
|
||||
func (u userToTagDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToTag, err error) {
|
||||
buf := make([]*models.UserToTag, 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 userToTagDo) FindInBatches(result *[]*models.UserToTag, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userToTagDo) Attrs(attrs ...field.AssignExpr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Assign(attrs ...field.AssignExpr) IUserToTagDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userToTagDo) Joins(fields ...field.RelationField) IUserToTagDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToTagDo) Preload(fields ...field.RelationField) IUserToTagDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToTagDo) FirstOrInit() (*models.UserToTag, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToTagDo) FirstOrCreate() (*models.UserToTag, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToTag), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToTagDo) FindByPage(offset int, limit int) (result []*models.UserToTag, 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 userToTagDo) 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 userToTagDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userToTagDo) Delete(models ...*models.UserToTag) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userToTagDo) withDO(do gen.Dao) *userToTagDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
544
storage-new/dbgen/user_to_user_relations.gen.go
Normal file
544
storage-new/dbgen/user_to_user_relations.gen.go
Normal file
|
@ -0,0 +1,544 @@
|
|||
// 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 newUserToUserRelation(db *gorm.DB, opts ...gen.DOOption) userToUserRelation {
|
||||
_userToUserRelation := userToUserRelation{}
|
||||
|
||||
_userToUserRelation.userToUserRelationDo.UseDB(db, opts...)
|
||||
_userToUserRelation.userToUserRelationDo.UseModel(&models.UserToUserRelation{})
|
||||
|
||||
tableName := _userToUserRelation.userToUserRelationDo.TableName()
|
||||
_userToUserRelation.ALL = field.NewAsterisk(tableName)
|
||||
_userToUserRelation.UserId = field.NewString(tableName, "user_id")
|
||||
_userToUserRelation.TargetUserId = field.NewString(tableName, "target_user_id")
|
||||
_userToUserRelation.Relation = field.NewField(tableName, "relation")
|
||||
_userToUserRelation.User = userToUserRelationBelongsToUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("User", "models.User"),
|
||||
}
|
||||
|
||||
_userToUserRelation.TargetUser = userToUserRelationBelongsToTargetUser{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("TargetUser", "models.User"),
|
||||
}
|
||||
|
||||
_userToUserRelation.fillFieldMap()
|
||||
|
||||
return _userToUserRelation
|
||||
}
|
||||
|
||||
type userToUserRelation struct {
|
||||
userToUserRelationDo
|
||||
|
||||
ALL field.Asterisk
|
||||
UserId field.String
|
||||
TargetUserId field.String
|
||||
Relation field.Field
|
||||
User userToUserRelationBelongsToUser
|
||||
|
||||
TargetUser userToUserRelationBelongsToTargetUser
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userToUserRelation) Table(newTableName string) *userToUserRelation {
|
||||
u.userToUserRelationDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userToUserRelation) As(alias string) *userToUserRelation {
|
||||
u.userToUserRelationDo.DO = *(u.userToUserRelationDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userToUserRelation) updateTableName(table string) *userToUserRelation {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.UserId = field.NewString(table, "user_id")
|
||||
u.TargetUserId = field.NewString(table, "target_user_id")
|
||||
u.Relation = field.NewField(table, "relation")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userToUserRelation) 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 *userToUserRelation) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 5)
|
||||
u.fieldMap["user_id"] = u.UserId
|
||||
u.fieldMap["target_user_id"] = u.TargetUserId
|
||||
u.fieldMap["relation"] = u.Relation
|
||||
|
||||
}
|
||||
|
||||
func (u userToUserRelation) clone(db *gorm.DB) userToUserRelation {
|
||||
u.userToUserRelationDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userToUserRelation) replaceDB(db *gorm.DB) userToUserRelation {
|
||||
u.userToUserRelationDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userToUserRelationBelongsToUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToUser) Where(conds ...field.Expr) *userToUserRelationBelongsToUser {
|
||||
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 userToUserRelationBelongsToUser) WithContext(ctx context.Context) *userToUserRelationBelongsToUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToUser) Session(session *gorm.Session) *userToUserRelationBelongsToUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToUser) Model(m *models.UserToUserRelation) *userToUserRelationBelongsToUserTx {
|
||||
return &userToUserRelationBelongsToUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToUserRelationBelongsToUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToUserRelationBelongsToUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToUserTx) 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 userToUserRelationBelongsToUserTx) 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 userToUserRelationBelongsToUserTx) 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 userToUserRelationBelongsToUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToUserRelationBelongsToTargetUser struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUser) Where(conds ...field.Expr) *userToUserRelationBelongsToTargetUser {
|
||||
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 userToUserRelationBelongsToTargetUser) WithContext(ctx context.Context) *userToUserRelationBelongsToTargetUser {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUser) Session(session *gorm.Session) *userToUserRelationBelongsToTargetUser {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUser) Model(m *models.UserToUserRelation) *userToUserRelationBelongsToTargetUserTx {
|
||||
return &userToUserRelationBelongsToTargetUserTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
type userToUserRelationBelongsToTargetUserTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUserTx) Find() (result *models.User, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUserTx) 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 userToUserRelationBelongsToTargetUserTx) 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 userToUserRelationBelongsToTargetUserTx) 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 userToUserRelationBelongsToTargetUserTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a userToUserRelationBelongsToTargetUserTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
type userToUserRelationDo struct{ gen.DO }
|
||||
|
||||
type IUserToUserRelationDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserToUserRelationDo
|
||||
WithContext(ctx context.Context) IUserToUserRelationDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserToUserRelationDo
|
||||
WriteDB() IUserToUserRelationDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserToUserRelationDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserToUserRelationDo
|
||||
Not(conds ...gen.Condition) IUserToUserRelationDo
|
||||
Or(conds ...gen.Condition) IUserToUserRelationDo
|
||||
Select(conds ...field.Expr) IUserToUserRelationDo
|
||||
Where(conds ...gen.Condition) IUserToUserRelationDo
|
||||
Order(conds ...field.Expr) IUserToUserRelationDo
|
||||
Distinct(cols ...field.Expr) IUserToUserRelationDo
|
||||
Omit(cols ...field.Expr) IUserToUserRelationDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo
|
||||
Group(cols ...field.Expr) IUserToUserRelationDo
|
||||
Having(conds ...gen.Condition) IUserToUserRelationDo
|
||||
Limit(limit int) IUserToUserRelationDo
|
||||
Offset(offset int) IUserToUserRelationDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToUserRelationDo
|
||||
Unscoped() IUserToUserRelationDo
|
||||
Create(values ...*models.UserToUserRelation) error
|
||||
CreateInBatches(values []*models.UserToUserRelation, batchSize int) error
|
||||
Save(values ...*models.UserToUserRelation) error
|
||||
First() (*models.UserToUserRelation, error)
|
||||
Take() (*models.UserToUserRelation, error)
|
||||
Last() (*models.UserToUserRelation, error)
|
||||
Find() ([]*models.UserToUserRelation, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToUserRelation, err error)
|
||||
FindInBatches(result *[]*models.UserToUserRelation, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.UserToUserRelation) (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) IUserToUserRelationDo
|
||||
Assign(attrs ...field.AssignExpr) IUserToUserRelationDo
|
||||
Joins(fields ...field.RelationField) IUserToUserRelationDo
|
||||
Preload(fields ...field.RelationField) IUserToUserRelationDo
|
||||
FirstOrInit() (*models.UserToUserRelation, error)
|
||||
FirstOrCreate() (*models.UserToUserRelation, error)
|
||||
FindByPage(offset int, limit int) (result []*models.UserToUserRelation, 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) IUserToUserRelationDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Debug() IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) WithContext(ctx context.Context) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) ReadDB() IUserToUserRelationDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) WriteDB() IUserToUserRelationDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Session(config *gorm.Session) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Clauses(conds ...clause.Expression) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Returning(value interface{}, columns ...string) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Not(conds ...gen.Condition) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Or(conds ...gen.Condition) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Select(conds ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Where(conds ...gen.Condition) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Order(conds ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Distinct(cols ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Omit(cols ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Join(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Group(cols ...field.Expr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Having(conds ...gen.Condition) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Limit(limit int) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Offset(offset int) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Unscoped() IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Create(values ...*models.UserToUserRelation) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) CreateInBatches(values []*models.UserToUserRelation, 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 userToUserRelationDo) Save(values ...*models.UserToUserRelation) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) First() (*models.UserToUserRelation, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToUserRelation), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Take() (*models.UserToUserRelation, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToUserRelation), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Last() (*models.UserToUserRelation, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToUserRelation), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Find() ([]*models.UserToUserRelation, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserToUserRelation), err
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserToUserRelation, err error) {
|
||||
buf := make([]*models.UserToUserRelation, 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 userToUserRelationDo) FindInBatches(result *[]*models.UserToUserRelation, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Attrs(attrs ...field.AssignExpr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Assign(attrs ...field.AssignExpr) IUserToUserRelationDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Joins(fields ...field.RelationField) IUserToUserRelationDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Preload(fields ...field.RelationField) IUserToUserRelationDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) FirstOrInit() (*models.UserToUserRelation, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToUserRelation), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) FirstOrCreate() (*models.UserToUserRelation, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserToUserRelation), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) FindByPage(offset int, limit int) (result []*models.UserToUserRelation, 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 userToUserRelationDo) 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 userToUserRelationDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userToUserRelationDo) Delete(models ...*models.UserToUserRelation) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userToUserRelationDo) withDO(do gen.Dao) *userToUserRelationDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
447
storage-new/dbgen/users.gen.go
Normal file
447
storage-new/dbgen/users.gen.go
Normal file
|
@ -0,0 +1,447 @@
|
|||
// 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 newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
||||
_user := user{}
|
||||
|
||||
_user.userDo.UseDB(db, opts...)
|
||||
_user.userDo.UseModel(&models.User{})
|
||||
|
||||
tableName := _user.userDo.TableName()
|
||||
_user.ALL = field.NewAsterisk(tableName)
|
||||
_user.ID = field.NewString(tableName, "id")
|
||||
_user.Username = field.NewString(tableName, "username")
|
||||
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_user.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_user.ServerId = field.NewUint(tableName, "server_id")
|
||||
_user.DisplayName = field.NewString(tableName, "display_name")
|
||||
_user.Description = field.NewString(tableName, "description")
|
||||
_user.IsBot = field.NewBool(tableName, "is_bot")
|
||||
_user.Icon = field.NewString(tableName, "icon")
|
||||
_user.Background = field.NewString(tableName, "background")
|
||||
_user.Banner = field.NewString(tableName, "banner")
|
||||
_user.Indexable = field.NewBool(tableName, "indexable")
|
||||
_user.PublicKey = field.NewBytes(tableName, "public_key")
|
||||
_user.RestrictedFollow = field.NewBool(tableName, "restricted_follow")
|
||||
_user.Location = field.NewString(tableName, "location")
|
||||
_user.Birthday = field.NewTime(tableName, "birthday")
|
||||
_user.Verified = field.NewBool(tableName, "verified")
|
||||
|
||||
_user.fillFieldMap()
|
||||
|
||||
return _user
|
||||
}
|
||||
|
||||
type user struct {
|
||||
userDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.String
|
||||
Username field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
ServerId field.Uint
|
||||
DisplayName field.String
|
||||
Description field.String
|
||||
IsBot field.Bool
|
||||
Icon field.String
|
||||
Background field.String
|
||||
Banner field.String
|
||||
Indexable field.Bool
|
||||
PublicKey field.Bytes
|
||||
RestrictedFollow field.Bool
|
||||
Location field.String
|
||||
Birthday field.Time
|
||||
Verified field.Bool
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u user) Table(newTableName string) *user {
|
||||
u.userDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u user) As(alias string) *user {
|
||||
u.userDo.DO = *(u.userDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *user) updateTableName(table string) *user {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewString(table, "id")
|
||||
u.Username = field.NewString(table, "username")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
u.ServerId = field.NewUint(table, "server_id")
|
||||
u.DisplayName = field.NewString(table, "display_name")
|
||||
u.Description = field.NewString(table, "description")
|
||||
u.IsBot = field.NewBool(table, "is_bot")
|
||||
u.Icon = field.NewString(table, "icon")
|
||||
u.Background = field.NewString(table, "background")
|
||||
u.Banner = field.NewString(table, "banner")
|
||||
u.Indexable = field.NewBool(table, "indexable")
|
||||
u.PublicKey = field.NewBytes(table, "public_key")
|
||||
u.RestrictedFollow = field.NewBool(table, "restricted_follow")
|
||||
u.Location = field.NewString(table, "location")
|
||||
u.Birthday = field.NewTime(table, "birthday")
|
||||
u.Verified = field.NewBool(table, "verified")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *user) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 18)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["username"] = u.Username
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
u.fieldMap["server_id"] = u.ServerId
|
||||
u.fieldMap["display_name"] = u.DisplayName
|
||||
u.fieldMap["description"] = u.Description
|
||||
u.fieldMap["is_bot"] = u.IsBot
|
||||
u.fieldMap["icon"] = u.Icon
|
||||
u.fieldMap["background"] = u.Background
|
||||
u.fieldMap["banner"] = u.Banner
|
||||
u.fieldMap["indexable"] = u.Indexable
|
||||
u.fieldMap["public_key"] = u.PublicKey
|
||||
u.fieldMap["restricted_follow"] = u.RestrictedFollow
|
||||
u.fieldMap["location"] = u.Location
|
||||
u.fieldMap["birthday"] = u.Birthday
|
||||
u.fieldMap["verified"] = u.Verified
|
||||
}
|
||||
|
||||
func (u user) clone(db *gorm.DB) user {
|
||||
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u user) replaceDB(db *gorm.DB) user {
|
||||
u.userDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userDo struct{ gen.DO }
|
||||
|
||||
type IUserDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IUserDo
|
||||
WithContext(ctx context.Context) IUserDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IUserDo
|
||||
WriteDB() IUserDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IUserDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IUserDo
|
||||
Not(conds ...gen.Condition) IUserDo
|
||||
Or(conds ...gen.Condition) IUserDo
|
||||
Select(conds ...field.Expr) IUserDo
|
||||
Where(conds ...gen.Condition) IUserDo
|
||||
Order(conds ...field.Expr) IUserDo
|
||||
Distinct(cols ...field.Expr) IUserDo
|
||||
Omit(cols ...field.Expr) IUserDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IUserDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IUserDo
|
||||
Group(cols ...field.Expr) IUserDo
|
||||
Having(conds ...gen.Condition) IUserDo
|
||||
Limit(limit int) IUserDo
|
||||
Offset(offset int) IUserDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo
|
||||
Unscoped() IUserDo
|
||||
Create(values ...*models.User) error
|
||||
CreateInBatches(values []*models.User, batchSize int) error
|
||||
Save(values ...*models.User) error
|
||||
First() (*models.User, error)
|
||||
Take() (*models.User, error)
|
||||
Last() (*models.User, error)
|
||||
Find() ([]*models.User, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.User, err error)
|
||||
FindInBatches(result *[]*models.User, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*models.User) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IUserDo
|
||||
Assign(attrs ...field.AssignExpr) IUserDo
|
||||
Joins(fields ...field.RelationField) IUserDo
|
||||
Preload(fields ...field.RelationField) IUserDo
|
||||
FirstOrInit() (*models.User, error)
|
||||
FirstOrCreate() (*models.User, error)
|
||||
FindByPage(offset int, limit int) (result []*models.User, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IUserDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (u userDo) Debug() IUserDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userDo) WithContext(ctx context.Context) IUserDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userDo) ReadDB() IUserDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userDo) WriteDB() IUserDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userDo) Session(config *gorm.Session) IUserDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userDo) Clauses(conds ...clause.Expression) IUserDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Returning(value interface{}, columns ...string) IUserDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userDo) Not(conds ...gen.Condition) IUserDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Or(conds ...gen.Condition) IUserDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Select(conds ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Where(conds ...gen.Condition) IUserDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Order(conds ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Distinct(cols ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Omit(cols ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Join(table schema.Tabler, on ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) Group(cols ...field.Expr) IUserDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Having(conds ...gen.Condition) IUserDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Limit(limit int) IUserDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userDo) Offset(offset int) IUserDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userDo) Unscoped() IUserDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userDo) Create(values ...*models.User) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userDo) CreateInBatches(values []*models.User, batchSize int) error {
|
||||
return u.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (u userDo) Save(values ...*models.User) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userDo) First() (*models.User, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Take() (*models.User, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Last() (*models.User, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Find() ([]*models.User, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.User), err
|
||||
}
|
||||
|
||||
func (u userDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.User, err error) {
|
||||
buf := make([]*models.User, 0, batchSize)
|
||||
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (u userDo) FindInBatches(result *[]*models.User, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userDo) Attrs(attrs ...field.AssignExpr) IUserDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userDo) Assign(attrs ...field.AssignExpr) IUserDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userDo) Joins(fields ...field.RelationField) IUserDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userDo) Preload(fields ...field.RelationField) IUserDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userDo) FirstOrInit() (*models.User, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) FirstOrCreate() (*models.User, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) FindByPage(offset int, limit int) (result []*models.User, count int64, err error) {
|
||||
result, err = u.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userDo) Delete(models ...*models.User) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userDo) withDO(do gen.Dao) *userDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
Loading…
Reference in a new issue