Update link repository use Links type
This commit is contained in:
parent
4c78b655ce
commit
221eb3f346
1 changed files with 4 additions and 4 deletions
|
|
@ -13,7 +13,7 @@ import (
|
||||||
type Repository interface {
|
type Repository interface {
|
||||||
Save(link *Link) error
|
Save(link *Link) error
|
||||||
FindById(id string) (*Link, error)
|
FindById(id string) (*Link, error)
|
||||||
FindAll(limit int, offset int) ([]Link, error)
|
FindAll(limit int, offset int) (Links, error)
|
||||||
DeleteById(id string) error
|
DeleteById(id string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ func (r *PgRepository) FindById(id string) (*Link, error) {
|
||||||
return entity, nil
|
return entity, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PgRepository) FindAll(limit int, offset int) ([]Link, error) {
|
func (r *PgRepository) FindAll(limit int, offset int) (Links, error) {
|
||||||
if limit < 0 {
|
if limit < 0 {
|
||||||
return nil, errors.New("limit can't be negative")
|
return nil, errors.New("limit can't be negative")
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ func (r *PgRepository) FindAll(limit int, offset int) ([]Link, error) {
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
links := make([]Link, 0)
|
links := make(Links, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
link, err := mapRowToEntity(rows)
|
link, err := mapRowToEntity(rows)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -118,7 +118,7 @@ func (r *PgRepository) FindAll(limit int, offset int) ([]Link, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
links = append(links, *link)
|
links = append(links, link)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = rows.Err(); err != nil {
|
if err = rows.Err(); err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue