// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: gallery_photos.sql package db import ( "context" "database/sql" ) const createGalleryPhoto = `-- name: CreateGalleryPhoto :one INSERT INTO gallery_photos (image_url, caption, created_at, show_on_home) VALUES ($1, $2, $3, $4) RETURNING id, image_url, caption, created_at, show_on_home ` type CreateGalleryPhotoParams struct { ImageUrl string `json:"image_url"` Caption sql.NullString `json:"caption"` CreatedAt sql.NullTime `json:"created_at"` ShowOnHome sql.NullBool `json:"show_on_home"` } func (q *Queries) CreateGalleryPhoto(ctx context.Context, arg CreateGalleryPhotoParams) (GalleryPhoto, error) { row := q.db.QueryRowContext(ctx, createGalleryPhoto, arg.ImageUrl, arg.Caption, arg.CreatedAt, arg.ShowOnHome, ) var i GalleryPhoto err := row.Scan( &i.ID, &i.ImageUrl, &i.Caption, &i.CreatedAt, &i.ShowOnHome, ) return i, err } const deleteGalleryPhoto = `-- name: DeleteGalleryPhoto :exec DELETE FROM gallery_photos WHERE id = $1 ` func (q *Queries) DeleteGalleryPhoto(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, deleteGalleryPhoto, id) return err } const listGalleryPhotos = `-- name: ListGalleryPhotos :many SELECT id, image_url, caption, created_at, show_on_home FROM gallery_photos ORDER BY created_at DESC ` func (q *Queries) ListGalleryPhotos(ctx context.Context) ([]GalleryPhoto, error) { rows, err := q.db.QueryContext(ctx, listGalleryPhotos) if err != nil { return nil, err } defer rows.Close() items := []GalleryPhoto{} for rows.Next() { var i GalleryPhoto if err := rows.Scan( &i.ID, &i.ImageUrl, &i.Caption, &i.CreatedAt, &i.ShowOnHome, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listHomeCarouselPhotos = `-- name: ListHomeCarouselPhotos :many SELECT id, image_url, caption, created_at, show_on_home FROM gallery_photos WHERE show_on_home = true ORDER BY created_at DESC ` func (q *Queries) ListHomeCarouselPhotos(ctx context.Context) ([]GalleryPhoto, error) { rows, err := q.db.QueryContext(ctx, listHomeCarouselPhotos) if err != nil { return nil, err } defer rows.Close() items := []GalleryPhoto{} for rows.Next() { var i GalleryPhoto if err := rows.Scan( &i.ID, &i.ImageUrl, &i.Caption, &i.CreatedAt, &i.ShowOnHome, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil }