short/internal/db/query.sql.go

41 lines
924 B
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: query.sql
package db
import (
"context"
)
const getURLByHash = `-- name: GetURLByHash :one
SELECT id, hash, long_url FROM urls
WHERE hash = $1
`
func (q *Queries) GetURLByHash(ctx context.Context, hash string) (Url, error) {
row := q.db.QueryRow(ctx, getURLByHash, hash)
var i Url
err := row.Scan(&i.ID, &i.Hash, &i.LongUrl)
return i, err
}
const insertURL = `-- name: InsertURL :one
INSERT INTO urls (hash, long_url)
VALUES ($1, $2)
ON CONFLICT (hash) DO UPDATE SET hash = EXCLUDED.hash -- force row to be returned
RETURNING id, hash, long_url
`
type InsertURLParams struct {
Hash string
LongUrl string
}
func (q *Queries) InsertURL(ctx context.Context, arg InsertURLParams) (Url, error) {
row := q.db.QueryRow(ctx, insertURL, arg.Hash, arg.LongUrl)
var i Url
err := row.Scan(&i.ID, &i.Hash, &i.LongUrl)
return i, err
}