|
|
|
|
@@ -46,12 +46,6 @@ func newContent(db *gorm.DB, opts ...gen.DOOption) contentQuery {
|
|
|
|
|
_contentQuery.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
|
|
|
_contentQuery.Key = field.NewString(tableName, "key")
|
|
|
|
|
_contentQuery.IsPinned = field.NewBool(tableName, "is_pinned")
|
|
|
|
|
_contentQuery.Comments = contentQueryHasManyComments{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("Comments", "Comment"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_contentQuery.Author = contentQueryBelongsToAuthor{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
@@ -64,6 +58,12 @@ func newContent(db *gorm.DB, opts ...gen.DOOption) contentQuery {
|
|
|
|
|
RelationField: field.NewRelation("ContentAssets", "ContentAsset"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_contentQuery.Comments = contentQueryHasManyComments{
|
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("Comments", "Comment"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_contentQuery.fillFieldMap()
|
|
|
|
|
|
|
|
|
|
return _contentQuery
|
|
|
|
|
@@ -94,12 +94,12 @@ type contentQuery struct {
|
|
|
|
|
DeletedAt field.Field
|
|
|
|
|
Key field.String // Musical key/tone
|
|
|
|
|
IsPinned field.Bool // Whether content is pinned/featured
|
|
|
|
|
Comments contentQueryHasManyComments
|
|
|
|
|
|
|
|
|
|
Author contentQueryBelongsToAuthor
|
|
|
|
|
Author contentQueryBelongsToAuthor
|
|
|
|
|
|
|
|
|
|
ContentAssets contentQueryHasManyContentAssets
|
|
|
|
|
|
|
|
|
|
Comments contentQueryHasManyComments
|
|
|
|
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -195,104 +195,23 @@ func (c *contentQuery) fillFieldMap() {
|
|
|
|
|
|
|
|
|
|
func (c contentQuery) clone(db *gorm.DB) contentQuery {
|
|
|
|
|
c.contentQueryDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
|
|
c.Comments.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
c.Comments.db.Statement.ConnPool = db.Statement.ConnPool
|
|
|
|
|
c.Author.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
c.Author.db.Statement.ConnPool = db.Statement.ConnPool
|
|
|
|
|
c.ContentAssets.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
c.ContentAssets.db.Statement.ConnPool = db.Statement.ConnPool
|
|
|
|
|
c.Comments.db = db.Session(&gorm.Session{Initialized: true})
|
|
|
|
|
c.Comments.db.Statement.ConnPool = db.Statement.ConnPool
|
|
|
|
|
return c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c contentQuery) replaceDB(db *gorm.DB) contentQuery {
|
|
|
|
|
c.contentQueryDo.ReplaceDB(db)
|
|
|
|
|
c.Comments.db = db.Session(&gorm.Session{})
|
|
|
|
|
c.Author.db = db.Session(&gorm.Session{})
|
|
|
|
|
c.ContentAssets.db = db.Session(&gorm.Session{})
|
|
|
|
|
c.Comments.db = db.Session(&gorm.Session{})
|
|
|
|
|
return c
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryHasManyComments struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Where(conds ...field.Expr) *contentQueryHasManyComments {
|
|
|
|
|
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 contentQueryHasManyComments) WithContext(ctx context.Context) *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Session(session *gorm.Session) *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Model(m *Content) *contentQueryHasManyCommentsTx {
|
|
|
|
|
return &contentQueryHasManyCommentsTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Unscoped() *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryHasManyCommentsTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Find() (result []*Comment, err error) {
|
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Append(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Append(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Replace(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Replace(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Delete(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Delete(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Clear() error {
|
|
|
|
|
return a.tx.Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Count() int64 {
|
|
|
|
|
return a.tx.Count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Unscoped() *contentQueryHasManyCommentsTx {
|
|
|
|
|
a.tx = a.tx.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryBelongsToAuthor struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
@@ -455,6 +374,87 @@ func (a contentQueryHasManyContentAssetsTx) Unscoped() *contentQueryHasManyConte
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryHasManyComments struct {
|
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
|
|
field.RelationField
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Where(conds ...field.Expr) *contentQueryHasManyComments {
|
|
|
|
|
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 contentQueryHasManyComments) WithContext(ctx context.Context) *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Session(session *gorm.Session) *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Model(m *Content) *contentQueryHasManyCommentsTx {
|
|
|
|
|
return &contentQueryHasManyCommentsTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyComments) Unscoped() *contentQueryHasManyComments {
|
|
|
|
|
a.db = a.db.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryHasManyCommentsTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Find() (result []*Comment, err error) {
|
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Append(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Append(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Replace(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Replace(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Delete(values ...*Comment) (err error) {
|
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
|
for i, v := range values {
|
|
|
|
|
targetValues[i] = v
|
|
|
|
|
}
|
|
|
|
|
return a.tx.Delete(targetValues...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Clear() error {
|
|
|
|
|
return a.tx.Clear()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Count() int64 {
|
|
|
|
|
return a.tx.Count()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a contentQueryHasManyCommentsTx) Unscoped() *contentQueryHasManyCommentsTx {
|
|
|
|
|
a.tx = a.tx.Unscoped()
|
|
|
|
|
return &a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type contentQueryDo struct{ gen.DO }
|
|
|
|
|
|
|
|
|
|
func (c contentQueryDo) Debug() *contentQueryDo {
|
|
|
|
|
|