Add get count all items from db, and review result struct
This commit is contained in:
1 parent
88ae5fa188
commit
f6bca0590f
3 files changed
+42
-4
No files matched your search
@@ -51,6 +51,19 @@ func (f *Filmsrepo) FindByAll() (*[]model.Films, error) {
|
||||
return &buffs, nil
|
||||
}
|
||||
|
||||
func (f *Filmsrepo) GetCountFilms() (*int, error) {
|
||||
rows, err := f.db.db.Query(context.Background(), "SELECT count(*) FROM films")
|
||||
var count int
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
rows.Scan(&count)
|
||||
}
|
||||
return &count, nil
|
||||
}
|
||||
|
||||
func (f *Filmsrepo) FindById(id string) (*model.Films, error) {
|
||||
query := fmt.Sprintf("SELECT * FROM films WHERE Id = %s;", id)
|
||||
var buff model.Films
|
||||
|
||||
Reference in new issue
Block a user