feat: fix issues
This commit is contained in:
@@ -48,12 +48,13 @@ func (m *Posts) CondLike(key *string) Cond {
|
||||
func (m *Posts) IncrViewCount(ctx context.Context) error {
|
||||
tbl := tblPosts
|
||||
|
||||
stmt := tbl.UPDATE(tbl.Views).SET(tbl.Views.ADD(Int64(1))).WHERE(tbl.ID.EQ(Int64(m.ID)))
|
||||
stmt := tbl.UPDATE(tbl.Views).
|
||||
SET(tbl.Views.ADD(Int64(1))).
|
||||
WHERE(tbl.ID.EQ(Int64(m.ID))).
|
||||
RETURNING(tblPosts.AllColumns)
|
||||
m.log().Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
var post Posts
|
||||
err := stmt.QueryContext(ctx, db, &post)
|
||||
if err != nil {
|
||||
if err := stmt.QueryContext(ctx, db, m); err != nil {
|
||||
m.log().Errorf("error updating post view count: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user