2026-10-03 09:15:40 -04:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
|
// versions:
|
|
|
|
|
// sqlc v1.31.1
|
|
|
|
|
// source: photos.sql
|
|
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const createPhoto = `-- name: CreatePhoto :one
|
|
|
|
|
INSERT INTO photos (
|
|
|
|
|
id, source_url, local_path, width, height, sha256, fetched_at,
|
|
|
|
|
created_at, updated_at
|
|
|
|
|
) VALUES (
|
|
|
|
|
?, ?, ?, ?, ?, ?, ?,
|
|
|
|
|
?, ?
|
|
|
|
|
)
|
|
|
|
|
RETURNING id, source_url, local_path, width, height, sha256, fetched_at, created_at, updated_at
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreatePhotoParams struct {
|
|
|
|
|
ID string
|
|
|
|
|
SourceUrl string
|
|
|
|
|
LocalPath string
|
|
|
|
|
Width int64
|
|
|
|
|
Height int64
|
|
|
|
|
Sha256 string
|
|
|
|
|
FetchedAt string
|
|
|
|
|
CreatedAt string
|
|
|
|
|
UpdatedAt string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) CreatePhoto(ctx context.Context, arg CreatePhotoParams) (Photo, error) {
|
|
|
|
|
row := q.db.QueryRowContext(ctx, createPhoto,
|
|
|
|
|
arg.ID,
|
|
|
|
|
arg.SourceUrl,
|
|
|
|
|
arg.LocalPath,
|
|
|
|
|
arg.Width,
|
|
|
|
|
arg.Height,
|
|
|
|
|
arg.Sha256,
|
|
|
|
|
arg.FetchedAt,
|
|
|
|
|
arg.CreatedAt,
|
|
|
|
|
arg.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
var i Photo
|
|
|
|
|
err := row.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
|
&i.SourceUrl,
|
|
|
|
|
&i.LocalPath,
|
|
|
|
|
&i.Width,
|
|
|
|
|
&i.Height,
|
|
|
|
|
&i.Sha256,
|
|
|
|
|
&i.FetchedAt,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-06 07:27:58 -04:00
|
|
|
const getPhoto = `-- name: GetPhoto :one
|
|
|
|
|
SELECT id, source_url, local_path, width, height, sha256, fetched_at, created_at, updated_at FROM photos
|
|
|
|
|
WHERE id = ?
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) GetPhoto(ctx context.Context, id string) (Photo, error) {
|
|
|
|
|
row := q.db.QueryRowContext(ctx, getPhoto, id)
|
|
|
|
|
var i Photo
|
|
|
|
|
err := row.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
|
&i.SourceUrl,
|
|
|
|
|
&i.LocalPath,
|
|
|
|
|
&i.Width,
|
|
|
|
|
&i.Height,
|
|
|
|
|
&i.Sha256,
|
|
|
|
|
&i.FetchedAt,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-03 09:15:40 -04:00
|
|
|
const getPhotoBySHA256 = `-- name: GetPhotoBySHA256 :one
|
|
|
|
|
SELECT id, source_url, local_path, width, height, sha256, fetched_at, created_at, updated_at FROM photos
|
|
|
|
|
WHERE sha256 = ?
|
|
|
|
|
ORDER BY id
|
|
|
|
|
LIMIT 1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
// Finds stored image bytes by content hash. The schema does not make sha256
|
|
|
|
|
// unique, so the earliest-created (lowest id) match is returned.
|
|
|
|
|
func (q *Queries) GetPhotoBySHA256(ctx context.Context, sha256 string) (Photo, error) {
|
|
|
|
|
row := q.db.QueryRowContext(ctx, getPhotoBySHA256, sha256)
|
|
|
|
|
var i Photo
|
|
|
|
|
err := row.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
|
&i.SourceUrl,
|
|
|
|
|
&i.LocalPath,
|
|
|
|
|
&i.Width,
|
|
|
|
|
&i.Height,
|
|
|
|
|
&i.Sha256,
|
|
|
|
|
&i.FetchedAt,
|
|
|
|
|
&i.CreatedAt,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|