| 1 | // Code generated by sqlc. DO NOT EDIT. |
| 2 | // versions: |
| 3 | // sqlc v1.31.1 |
| 4 | // source: queries.sql |
| 5 | |
| 6 | package metadb |
| 7 | |
| 8 | import ( |
| 9 | "context" |
| 10 | ) |
| 11 | |
| 12 | const deleteMeta = `-- name: DeleteMeta :exec |
| 13 | DELETE FROM meta WHERE key = $1 |
| 14 | ` |
| 15 | |
| 16 | func (q *Queries) DeleteMeta(ctx context.Context, db DBTX, key string) error { |
| 17 | _, err := db.Exec(ctx, deleteMeta, key) |
| 18 | return err |
| 19 | } |
| 20 | |
| 21 | const getMeta = `-- name: GetMeta :one |
| 22 | |
| 23 | SELECT key, value, updated_at |
| 24 | FROM meta |
| 25 | WHERE key = $1 |
| 26 | ` |
| 27 | |
| 28 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 29 | func (q *Queries) GetMeta(ctx context.Context, db DBTX, key string) (Meta, error) { |
| 30 | row := db.QueryRow(ctx, getMeta, key) |
| 31 | var i Meta |
| 32 | err := row.Scan(&i.Key, &i.Value, &i.UpdatedAt) |
| 33 | return i, err |
| 34 | } |
| 35 | |
| 36 | const listMeta = `-- name: ListMeta :many |
| 37 | SELECT key, value, updated_at |
| 38 | FROM meta |
| 39 | ORDER BY key |
| 40 | ` |
| 41 | |
| 42 | func (q *Queries) ListMeta(ctx context.Context, db DBTX) ([]Meta, error) { |
| 43 | rows, err := db.Query(ctx, listMeta) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | defer rows.Close() |
| 48 | items := []Meta{} |
| 49 | for rows.Next() { |
| 50 | var i Meta |
| 51 | if err := rows.Scan(&i.Key, &i.Value, &i.UpdatedAt); err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | items = append(items, i) |
| 55 | } |
| 56 | if err := rows.Err(); err != nil { |
| 57 | return nil, err |
| 58 | } |
| 59 | return items, nil |
| 60 | } |
| 61 | |
| 62 | const setMeta = `-- name: SetMeta :exec |
| 63 | INSERT INTO meta (key, value) |
| 64 | VALUES ($1, $2) |
| 65 | ON CONFLICT (key) DO UPDATE |
| 66 | SET value = EXCLUDED.value |
| 67 | ` |
| 68 | |
| 69 | type SetMetaParams struct { |
| 70 | Key string |
| 71 | Value []byte |
| 72 | } |
| 73 | |
| 74 | func (q *Queries) SetMeta(ctx context.Context, db DBTX, arg SetMetaParams) error { |
| 75 | _, err := db.Exec(ctx, setMeta, arg.Key, arg.Value) |
| 76 | return err |
| 77 | } |
| 78 |