sqldb/sqlc: add NodeExists query

This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:20 +02:00
1 parent 1738e0cabc
commit 5a3c013e91
3 files changed
+30

No files matched your search

+21
View File
@@ -3537,6 +3537,27 @@ func (q *Queries) ListNodesPaginated(ctx context.Context, arg ListNodesPaginated
return items, nil return items, nil
} }
const nodeExists = `-- name: NodeExists :one
SELECT EXISTS (
SELECT 1
FROM graph_nodes
WHERE pub_key = $1
AND version = $2
) AS node_exists
`
type NodeExistsParams struct {
PubKey []byte
Version int16
}
func (q *Queries) NodeExists(ctx context.Context, arg NodeExistsParams) (bool, error) {
row := q.db.QueryRowContext(ctx, nodeExists, arg.PubKey, arg.Version)
var node_exists bool
err := row.Scan(&node_exists)
return node_exists, err
}
const upsertChanPolicyExtraType = `-- name: UpsertChanPolicyExtraType :exec const upsertChanPolicyExtraType = `-- name: UpsertChanPolicyExtraType :exec
/* ───────────────────────────────────────────── /* ─────────────────────────────────────────────
graph_channel_policy_extra_types table queries graph_channel_policy_extra_types table queries
+1
View File
@@ -125,6 +125,7 @@ type Querier interface {
ListNodeIDsAndPubKeys(ctx context.Context, arg ListNodeIDsAndPubKeysParams) ([]ListNodeIDsAndPubKeysRow, error) ListNodeIDsAndPubKeys(ctx context.Context, arg ListNodeIDsAndPubKeysParams) ([]ListNodeIDsAndPubKeysRow, error)
ListNodesPaginated(ctx context.Context, arg ListNodesPaginatedParams) ([]GraphNode, error) ListNodesPaginated(ctx context.Context, arg ListNodesPaginatedParams) ([]GraphNode, error)
NextInvoiceSettleIndex(ctx context.Context) (int64, error) NextInvoiceSettleIndex(ctx context.Context) (int64, error)
NodeExists(ctx context.Context, arg NodeExistsParams) (bool, error)
OnAMPSubInvoiceCanceled(ctx context.Context, arg OnAMPSubInvoiceCanceledParams) error OnAMPSubInvoiceCanceled(ctx context.Context, arg OnAMPSubInvoiceCanceledParams) error
OnAMPSubInvoiceCreated(ctx context.Context, arg OnAMPSubInvoiceCreatedParams) error OnAMPSubInvoiceCreated(ctx context.Context, arg OnAMPSubInvoiceCreatedParams) error
OnAMPSubInvoiceSettled(ctx context.Context, arg OnAMPSubInvoiceSettledParams) error OnAMPSubInvoiceSettled(ctx context.Context, arg OnAMPSubInvoiceSettledParams) error
+8
View File
@@ -59,6 +59,14 @@ FROM graph_nodes
WHERE pub_key = $1 WHERE pub_key = $1
AND version = $2; AND version = $2;
-- name: NodeExists :one
SELECT EXISTS (
SELECT 1
FROM graph_nodes
WHERE pub_key = $1
AND version = $2
) AS node_exists;
-- name: GetNodeIDByPubKey :one -- name: GetNodeIDByPubKey :one
SELECT id SELECT id
FROM graph_nodes FROM graph_nodes