Skip to content

Commit

Permalink
T | fix duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ton.R committed May 19, 2024
1 parent 7b04080 commit 12da540
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions api/transaction/getFilteredTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ func (h handler) GetFilteredTransaction(c echo.Context) error {
query += " ORDER BY date DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"
args = append(args, offset, limit)

rows, err := h.db.QueryContext(ctx, query, args...)
if err != nil {
logger.Error("query error", zap.Error(err))
return c.JSON(http.StatusInternalServerError, err.Error())
rows, err2 := h.db.QueryContext(ctx, query, args...)
if err2 != nil {
logger.Error("query error", zap.Error(err2))
return c.JSON(http.StatusInternalServerError, err2.Error())
}
defer rows.Close()

var trans []Transaction
for rows.Next() {
var tran Transaction
err := rows.Scan(&tran.Id, &tran.Date, &tran.Amount, &tran.Catergory, &tran.TransactionType, &tran.Note, &tran.ImageUrl, &tran.SpenderId)
if err != nil {
logger.Error("scan error", zap.Error(err))
return c.JSON(http.StatusInternalServerError, err.Error())
err3 := rows.Scan(&tran.Id, &tran.Date, &tran.Amount, &tran.Catergory, &tran.TransactionType, &tran.Note, &tran.ImageUrl, &tran.SpenderId)
if err3 != nil {
logger.Error("scan error", zap.Error(err3))
return c.JSON(http.StatusInternalServerError, err3.Error())
}
trans = append(trans, tran)
}
Expand Down

0 comments on commit 12da540

Please sign in to comment.