feat: update admin
This commit is contained in:
@@ -395,3 +395,21 @@ func (m *postsModel) GetMediaByIds(ctx context.Context, ids []int64) ([]model.Me
|
||||
|
||||
return medias, nil
|
||||
}
|
||||
|
||||
// Count
|
||||
func (m *postsModel) Count(ctx context.Context, cond BoolExpression) (int64, error) {
|
||||
tbl := table.Posts
|
||||
stmt := tbl.
|
||||
SELECT(COUNT(tbl.ID).AS("count")).
|
||||
WHERE(cond)
|
||||
|
||||
var count struct {
|
||||
Count int64
|
||||
}
|
||||
if err := stmt.QueryContext(ctx, db, &count); err != nil {
|
||||
m.log.Errorf("error counting posts: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count.Count, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user