feat: update admin
This commit is contained in:
@@ -257,3 +257,21 @@ func (m *mediasModel) GetRelations(ctx context.Context, hash string) ([]*model.M
|
||||
return &media
|
||||
}), nil
|
||||
}
|
||||
|
||||
// Count
|
||||
func (m *mediasModel) Count(ctx context.Context) (int64, error) {
|
||||
tbl := table.Medias
|
||||
stmt := tbl.SELECT(COUNT(tbl.ID).AS("count"))
|
||||
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||
|
||||
var count struct {
|
||||
Count int64
|
||||
}
|
||||
|
||||
if err := stmt.QueryContext(ctx, db, &count); err != nil {
|
||||
m.log.Errorf("error counting media items: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return count.Count, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user