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