// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: snapshots.sql package sqlc import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const insertSnapshot = `-- name: InsertSnapshot :exec INSERT INTO snapshots (id, container_id, parent_snapshot_id, snapshotter, digest) VALUES ( $1, $2, $3, $4, $5 ) ON CONFLICT (id) DO NOTHING ` type InsertSnapshotParams struct { ID string `json:"id"` ContainerID string `json:"container_id"` ParentSnapshotID pgtype.Text `json:"parent_snapshot_id"` Snapshotter string `json:"snapshotter"` Digest pgtype.Text `json:"digest"` } func (q *Queries) InsertSnapshot(ctx context.Context, arg InsertSnapshotParams) error { _, err := q.db.Exec(ctx, insertSnapshot, arg.ID, arg.ContainerID, arg.ParentSnapshotID, arg.Snapshotter, arg.Digest, ) return err } const listSnapshotsByContainerID = `-- name: ListSnapshotsByContainerID :many SELECT id, container_id, parent_snapshot_id, snapshotter, digest, created_at FROM snapshots WHERE container_id = $1 ORDER BY created_at ASC ` func (q *Queries) ListSnapshotsByContainerID(ctx context.Context, containerID string) ([]Snapshot, error) { rows, err := q.db.Query(ctx, listSnapshotsByContainerID, containerID) if err != nil { return nil, err } defer rows.Close() var items []Snapshot for rows.Next() { var i Snapshot if err := rows.Scan( &i.ID, &i.ContainerID, &i.ParentSnapshotID, &i.Snapshotter, &i.Digest, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil }