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
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue