mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
sqlc+firewalldb: add GetAction SQL query
Add a new SQL query `GetAction` to retrieve a single action by its ID. This query will be needed for the kvdb to SQL migration of actions store.
This commit is contained in:
parent
c2c63cc241
commit
5d8f03e241
4 changed files with 36 additions and 0 deletions
|
|
@ -11,6 +11,34 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const getAction = `-- name: GetAction :one
|
||||
SELECT id, session_id, account_id, macaroon_identifier, actor_name, feature_name, action_trigger, intent, structured_json_data, rpc_method, rpc_params_json, created_at, action_state, error_reason
|
||||
FROM actions
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAction(ctx context.Context, id int64) (Action, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAction, id)
|
||||
var i Action
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.SessionID,
|
||||
&i.AccountID,
|
||||
&i.MacaroonIdentifier,
|
||||
&i.ActorName,
|
||||
&i.FeatureName,
|
||||
&i.ActionTrigger,
|
||||
&i.Intent,
|
||||
&i.StructuredJsonData,
|
||||
&i.RpcMethod,
|
||||
&i.RpcParamsJson,
|
||||
&i.CreatedAt,
|
||||
&i.ActionState,
|
||||
&i.ErrorReason,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertAction = `-- name: InsertAction :one
|
||||
INSERT INTO actions (
|
||||
session_id, account_id, macaroon_identifier, actor_name, feature_name, action_trigger,
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ type Querier interface {
|
|||
GetAccountIndex(ctx context.Context, name string) (int64, error)
|
||||
GetAccountInvoice(ctx context.Context, arg GetAccountInvoiceParams) (AccountInvoice, error)
|
||||
GetAccountPayment(ctx context.Context, arg GetAccountPaymentParams) (AccountPayment, error)
|
||||
GetAction(ctx context.Context, id int64) (Action, error)
|
||||
GetAliasBySessionID(ctx context.Context, id int64) ([]byte, error)
|
||||
GetAllPrivacyPairs(ctx context.Context, groupID int64) ([]GetAllPrivacyPairsRow, error)
|
||||
GetFeatureID(ctx context.Context, name string) (int64, error)
|
||||
|
|
|
|||
|
|
@ -13,3 +13,9 @@ UPDATE actions
|
|||
SET action_state = $1,
|
||||
error_reason = $2
|
||||
WHERE id = $3;
|
||||
|
||||
|
||||
-- name: GetAction :one
|
||||
SELECT *
|
||||
FROM actions
|
||||
WHERE id = $1;
|
||||
|
|
@ -35,6 +35,7 @@ type SQLActionQueries interface {
|
|||
SetActionState(ctx context.Context, arg sqlc.SetActionStateParams) error
|
||||
ListActions(ctx context.Context, arg sqlc.ListActionsParams) ([]sqlc.Action, error)
|
||||
CountActions(ctx context.Context, arg sqlc.ActionQueryParams) (int64, error)
|
||||
GetAction(ctx context.Context, id int64) (sqlc.Action, error)
|
||||
}
|
||||
|
||||
// sqlActionLocator helps us find an action in the SQL DB.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue