discordBots/pkg/db/query.sql.go
2024-07-12 13:53:17 +00:00

58 lines
1 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// 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
}