Go · 2128 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 ON CONFLICT (step_id, seq) DO NOTHING
19 RETURNING id, step_id, seq, created_at
20 `
21
22 type AppendStepLogChunkParams struct {
23 StepID int64
24 Seq int32
25 Chunk []byte
26 }
27
28 type AppendStepLogChunkRow struct {
29 ID int64
30 StepID int64
31 Seq int32
32 CreatedAt pgtype.Timestamptz
33 }
34
35 // SPDX-License-Identifier: AGPL-3.0-or-later
36 func (q *Queries) AppendStepLogChunk(ctx context.Context, db DBTX, arg AppendStepLogChunkParams) (AppendStepLogChunkRow, error) {
37 row := db.QueryRow(ctx, appendStepLogChunk, arg.StepID, arg.Seq, arg.Chunk)
38 var i AppendStepLogChunkRow
39 err := row.Scan(
40 &i.ID,
41 &i.StepID,
42 &i.Seq,
43 &i.CreatedAt,
44 )
45 return i, err
46 }
47
48 const deleteStepLogChunks = `-- name: DeleteStepLogChunks :exec
49 DELETE FROM workflow_step_log_chunks WHERE step_id = $1
50 `
51
52 func (q *Queries) DeleteStepLogChunks(ctx context.Context, db DBTX, stepID int64) error {
53 _, err := db.Exec(ctx, deleteStepLogChunks, stepID)
54 return err
55 }
56
57 const listStepLogChunks = `-- name: ListStepLogChunks :many
58 SELECT id, step_id, seq, chunk, created_at
59 FROM workflow_step_log_chunks
60 WHERE step_id = $1 AND seq > $2
61 ORDER BY seq ASC
62 LIMIT $3
63 `
64
65 type ListStepLogChunksParams struct {
66 StepID int64
67 Seq int32
68 Limit int32
69 }
70
71 func (q *Queries) ListStepLogChunks(ctx context.Context, db DBTX, arg ListStepLogChunksParams) ([]WorkflowStepLogChunk, error) {
72 rows, err := db.Query(ctx, listStepLogChunks, arg.StepID, arg.Seq, arg.Limit)
73 if err != nil {
74 return nil, err
75 }
76 defer rows.Close()
77 items := []WorkflowStepLogChunk{}
78 for rows.Next() {
79 var i WorkflowStepLogChunk
80 if err := rows.Scan(
81 &i.ID,
82 &i.StepID,
83 &i.Seq,
84 &i.Chunk,
85 &i.CreatedAt,
86 ); err != nil {
87 return nil, err
88 }
89 items = append(items, i)
90 }
91 if err := rows.Err(); err != nil {
92 return nil, err
93 }
94 return items, nil
95 }
96