Prep for reactions, some fixes and improvements
Some checks failed
/ docker (push) Failing after 1m35s
Some checks failed
/ docker (push) Failing after 1m35s
This commit is contained in:
parent
4b62c32247
commit
8947d97825
13 changed files with 262 additions and 43 deletions
|
@ -30,6 +30,8 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
_noteToFeed.ID = field.NewUint64(tableName, "id")
|
||||
_noteToFeed.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_noteToFeed.NoteId = field.NewString(tableName, "note_id")
|
||||
_noteToFeed.FeedId = field.NewUint64(tableName, "feed_id")
|
||||
_noteToFeed.Reason = field.NewString(tableName, "reason")
|
||||
_noteToFeed.Note = noteToFeedBelongsToNote{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
|
@ -399,6 +401,17 @@ func newNoteToFeed(db *gorm.DB, opts ...gen.DOOption) noteToFeed {
|
|||
},
|
||||
}
|
||||
|
||||
_noteToFeed.Feed = noteToFeedBelongsToFeed{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Feed", "models.Feed"),
|
||||
Owner: struct {
|
||||
field.RelationField
|
||||
}{
|
||||
RelationField: field.NewRelation("Feed.Owner", "models.User"),
|
||||
},
|
||||
}
|
||||
|
||||
_noteToFeed.fillFieldMap()
|
||||
|
||||
return _noteToFeed
|
||||
|
@ -411,8 +424,12 @@ type noteToFeed struct {
|
|||
ID field.Uint64
|
||||
CreatedAt field.Time
|
||||
NoteId field.String
|
||||
FeedId field.Uint64
|
||||
Reason field.String
|
||||
Note noteToFeedBelongsToNote
|
||||
|
||||
Feed noteToFeedBelongsToFeed
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
|
@ -431,6 +448,8 @@ func (n *noteToFeed) updateTableName(table string) *noteToFeed {
|
|||
n.ID = field.NewUint64(table, "id")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.NoteId = field.NewString(table, "note_id")
|
||||
n.FeedId = field.NewUint64(table, "feed_id")
|
||||
n.Reason = field.NewString(table, "reason")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
|
@ -447,10 +466,12 @@ func (n *noteToFeed) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|||
}
|
||||
|
||||
func (n *noteToFeed) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 4)
|
||||
n.fieldMap = make(map[string]field.Expr, 7)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["note_id"] = n.NoteId
|
||||
n.fieldMap["feed_id"] = n.FeedId
|
||||
n.fieldMap["reason"] = n.Reason
|
||||
|
||||
}
|
||||
|
||||
|
@ -458,12 +479,15 @@ func (n noteToFeed) clone(db *gorm.DB) noteToFeed {
|
|||
n.noteToFeedDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
n.Note.db = db.Session(&gorm.Session{Initialized: true})
|
||||
n.Note.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
n.Feed.db = db.Session(&gorm.Session{Initialized: true})
|
||||
n.Feed.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return n
|
||||
}
|
||||
|
||||
func (n noteToFeed) replaceDB(db *gorm.DB) noteToFeed {
|
||||
n.noteToFeedDo.ReplaceDB(db)
|
||||
n.Note.db = db.Session(&gorm.Session{})
|
||||
n.Feed.db = db.Session(&gorm.Session{})
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -675,6 +699,91 @@ func (a noteToFeedBelongsToNoteTx) Unscoped() *noteToFeedBelongsToNoteTx {
|
|||
return &a
|
||||
}
|
||||
|
||||
type noteToFeedBelongsToFeed struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
|
||||
Owner struct {
|
||||
field.RelationField
|
||||
}
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeed) Where(conds ...field.Expr) *noteToFeedBelongsToFeed {
|
||||
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 noteToFeedBelongsToFeed) WithContext(ctx context.Context) *noteToFeedBelongsToFeed {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeed) Session(session *gorm.Session) *noteToFeedBelongsToFeed {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeed) Model(m *models.NoteToFeed) *noteToFeedBelongsToFeedTx {
|
||||
return ¬eToFeedBelongsToFeedTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeed) Unscoped() *noteToFeedBelongsToFeed {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToFeedBelongsToFeedTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Find() (result *models.Feed, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Append(values ...*models.Feed) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Replace(values ...*models.Feed) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Delete(values ...*models.Feed) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a noteToFeedBelongsToFeedTx) Unscoped() *noteToFeedBelongsToFeedTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type noteToFeedDo struct{ gen.DO }
|
||||
|
||||
type INoteToFeedDo interface {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue