Skip to content

Commit

Permalink
feat: voucher_repository FindAll method
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Oshiro committed Jan 23, 2025
1 parent bc54076 commit a3f3146
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/convenience/repository/voucher_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,29 @@ func (c *VoucherRepository) count(
return count, nil
}

func (c *VoucherRepository) FindAll(
ctx context.Context,
) ([]model.ConvenienceVoucher, error) {
query := `SELECT * FROM vouchers `
stmt, err := c.Db.Preparex(query)
if err != nil {
return nil, err
}
defer stmt.Close()
var rows []voucherRow
err = stmt.SelectContext(ctx, &rows)
if err != nil {
return nil, err
}

vouchers := make([]model.ConvenienceVoucher, len(rows))

for i, row := range rows {
vouchers[i] = convertToConvenienceVoucher(row)
}
return vouchers, nil
}

func (c *VoucherRepository) FindAllVouchers(
ctx context.Context,
first *int,
Expand Down

0 comments on commit a3f3146

Please sign in to comment.