summaryrefslogtreecommitdiff
path: root/model/rexps.sql.go
blob: 9b32c5b33328097f7cc2f23a5b925a7ddc1b6d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.25.0
// source: rexps.sql

package model

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const getRecurExpenses = `-- name: GetRecurExpenses :many
SELECT id, description, expense, duration, start, "end"
  FROM recur_expenses
 WHERE user_id = $1
`

type GetRecurExpensesRow struct {
	ID          int32
	Description pgtype.Text
	Expense     pgtype.Numeric
	Duration    pgtype.Interval
	Start       pgtype.Date
	End         pgtype.Date
}

// GetRecurExpenses
//
//	SELECT id, description, expense, duration, start, "end"
//	  FROM recur_expenses
//	 WHERE user_id = $1
func (q *Queries) GetRecurExpenses(ctx context.Context, userID int32) ([]GetRecurExpensesRow, error) {
	rows, err := q.db.Query(ctx, getRecurExpenses, userID)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	var items []GetRecurExpensesRow
	for rows.Next() {
		var i GetRecurExpensesRow
		if err := rows.Scan(
			&i.ID,
			&i.Description,
			&i.Expense,
			&i.Duration,
			&i.Start,
			&i.End,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}