sqldb: add invoice event queries

This commit is contained in:
positiveblue 2023-06-05 21:17:00 -07:00
parent fb16287b31
commit 877b711360
No known key found for this signature in database
GPG Key ID: 4FFF2510928804DC

View File

@ -0,0 +1,35 @@
-- name: InsertInvoiceEvent :exec
INSERT INTO invoice_events (
created_at, invoice_id, htlc_id, set_id, event_type, event_metadata
) VALUES (
$1, $2, $3, $4, $5, $6
);
-- name: SelectInvoiceEvents :many
SELECT *
FROM invoice_events
WHERE (
invoice_id = sqlc.narg('invoice_id') OR
sqlc.narg('invoice_id') IS NULL
) AND (
htlc_id = sqlc.narg('htlc_id') OR
sqlc.narg('htlc_id') IS NULL
) AND (
set_id = sqlc.narg('set_id') OR
sqlc.narg('set_id') IS NULL
) AND (
event_type = sqlc.narg('event_type') OR
sqlc.narg('event_type') IS NULL
) AND (
created_at >= sqlc.narg('created_after') OR
sqlc.narg('created_after') IS NULL
) AND (
created_at <= sqlc.narg('created_before') OR
sqlc.narg('created_before') IS NULL
)
LIMIT @num_limit OFFSET @num_offset;
-- name: DeleteInvoiceEvents :exec
DELETE
FROM invoice_events
WHERE invoice_id = $1;