2024-07-12 13:50:20 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
2024-07-12 13:51:53 +00:00
|
|
|
// sqlc v1.26.0
|
2024-07-12 13:50:20 +00:00
|
|
|
// source: query.sql
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
const countItems = `-- name: CountItems :one
|
|
|
|
SELECT count(*)
|
|
|
|
FROM store
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) CountItems(ctx context.Context) (int64, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, countItems)
|
|
|
|
var count int64
|
|
|
|
err := row.Scan(&count)
|
|
|
|
return count, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const createItem = `-- name: CreateItem :exec
|
|
|
|
INSERT INTO store (id, data)
|
|
|
|
VALUES (?1, ?2)
|
|
|
|
ON CONFLICT(id)
|
|
|
|
DO UPDATE SET data = ?2
|
|
|
|
`
|
|
|
|
|
|
|
|
type CreateItemParams struct {
|
|
|
|
ID string
|
|
|
|
Data []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) CreateItem(ctx context.Context, arg CreateItemParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, createItem, arg.ID, arg.Data)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
const getItem = `-- name: GetItem :one
|
|
|
|
SELECT id, data, created_at, updated_at
|
|
|
|
FROM store
|
|
|
|
WHERE id = ?
|
|
|
|
LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) GetItem(ctx context.Context, id string) (Store, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, getItem, id)
|
|
|
|
var i Store
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
|
|
|
&i.Data,
|
|
|
|
&i.CreatedAt,
|
|
|
|
&i.UpdatedAt,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|