Skip to content

Commit 9d1f0b8

Browse files
committed
improve get all payments query
1 parent 969fea8 commit 9d1f0b8

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

db/queries/payments.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ WHERE p.id = $1;
1818

1919

2020
-- name: GetAllPayments :many
21-
SELECT * FROM payment;
21+
SELECT p.id, t.name AS tenant_name,
22+
t.id AS tenant_id,p.amount, p.start_date, p.end_date, a.email AS admin_email, h.location, h.block, h.partition,
23+
p.created_at , p.updated_at, p.version
24+
FROM payment p
25+
JOIN tenant t ON p.tenant_id = t.id
26+
JOIN house h ON t.house_id = h.id
27+
JOIN admin a ON p.created_by = a.id;
2228

2329

2430
-- name: UpdatePayment :exec

db/sqlc/payments.sql.go

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/querier.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)