Go · 2090 bytes Raw Blame History
1 // Code generated by sqlc. DO NOT EDIT.
2 // versions:
3 // sqlc v1.31.1
4 // source: workflow_step_log_chunks.sql
5
6 package actionsdb
7
8 import (
9 "context"
10
11 "github.com/jackc/pgx/v5/pgtype"
12 )
13
14 const appendStepLogChunk = `-- name: AppendStepLogChunk :one
15
16 INSERT INTO workflow_step_log_chunks (step_id, seq, chunk)
17 VALUES ($1, $2, $3)
18 RETURNING id, step_id, seq, created_at
19 `
20
21 type AppendStepLogChunkParams struct {
22 StepID int64
23 Seq int32
24 Chunk []byte
25 }
26
27 type AppendStepLogChunkRow struct {
28 ID int64
29 StepID int64
30 Seq int32
31 CreatedAt pgtype.Timestamptz
32 }
33
34 // SPDX-License-Identifier: AGPL-3.0-or-later
35 func (q *Queries) AppendStepLogChunk(ctx context.Context, db DBTX, arg AppendStepLogChunkParams) (AppendStepLogChunkRow, error) {
36 row := db.QueryRow(ctx, appendStepLogChunk, arg.StepID, arg.Seq, arg.Chunk)
37 var i AppendStepLogChunkRow
38 err := row.Scan(
39 &i.ID,
40 &i.StepID,
41 &i.Seq,
42 &i.CreatedAt,
43 )
44 return i, err
45 }
46
47 const deleteStepLogChunks = `-- name: DeleteStepLogChunks :exec
48 DELETE FROM workflow_step_log_chunks WHERE step_id = $1
49 `
50
51 func (q *Queries) DeleteStepLogChunks(ctx context.Context, db DBTX, stepID int64) error {
52 _, err := db.Exec(ctx, deleteStepLogChunks, stepID)
53 return err
54 }
55
56 const listStepLogChunks = `-- name: ListStepLogChunks :many
57 SELECT id, step_id, seq, chunk, created_at
58 FROM workflow_step_log_chunks
59 WHERE step_id = $1 AND seq > $2
60 ORDER BY seq ASC
61 LIMIT $3
62 `
63
64 type ListStepLogChunksParams struct {
65 StepID int64
66 Seq int32
67 Limit int32
68 }
69
70 func (q *Queries) ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error) {
71 rows, err := db.Query(ctx, listStepLogChunks, arg.StepID, arg.Seq, arg.Limit)
72 if err != nil {
73 return nil, err
74 }
75 defer rows.Close()
76 items := []WorkflowStepLogChunk{}
77 for rows.Next() {
78 var i WorkflowStepLogChunk
79 if err := rows.Scan(
80 &i.ID,
81 &i.StepID,
82 &i.Seq,
83 &i.Chunk,
84 &i.CreatedAt,
85 ); err != nil {
86 return nil, err
87 }
88 items = append(items, i)
89 }
90 if err := rows.Err(); err != nil {
91 return nil, err
92 }
93 return items, nil
94 }
95