// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: uploads.sql package sqlgen import ( "context" ) const deleteUpload = `-- name: DeleteUpload :exec DELETE FROM uploads WHERE id = ? ` func (q *Queries) DeleteUpload(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, deleteUpload, id) return err } const insertUpload = `-- name: InsertUpload :exec INSERT INTO uploads ( site_id, guid, mime_type, filename, file_size, slug, alt, created_at ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id ` type InsertUploadParams struct { SiteID int64 Guid string MimeType string Filename string FileSize int64 Slug string Alt string CreatedAt int64 } func (q *Queries) InsertUpload(ctx context.Context, arg InsertUploadParams) error { _, err := q.db.ExecContext(ctx, insertUpload, arg.SiteID, arg.Guid, arg.MimeType, arg.Filename, arg.FileSize, arg.Slug, arg.Alt, arg.CreatedAt, ) return err } const selectUploadByID = `-- name: SelectUploadByID :one SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE id = ? LIMIT 1 ` func (q *Queries) SelectUploadByID(ctx context.Context, id int64) (Upload, error) { row := q.db.QueryRowContext(ctx, selectUploadByID, id) var i Upload err := row.Scan( &i.ID, &i.SiteID, &i.Guid, &i.MimeType, &i.Filename, &i.FileSize, &i.Slug, &i.Alt, &i.CreatedAt, ) return i, err } const selectUploadBySiteIDAndSlug = `-- name: SelectUploadBySiteIDAndSlug :one SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE site_id = ? AND slug = ? LIMIT 1 ` type SelectUploadBySiteIDAndSlugParams struct { SiteID int64 Slug string } func (q *Queries) SelectUploadBySiteIDAndSlug(ctx context.Context, arg SelectUploadBySiteIDAndSlugParams) (Upload, error) { row := q.db.QueryRowContext(ctx, selectUploadBySiteIDAndSlug, arg.SiteID, arg.Slug) var i Upload err := row.Scan( &i.ID, &i.SiteID, &i.Guid, &i.MimeType, &i.Filename, &i.FileSize, &i.Slug, &i.Alt, &i.CreatedAt, ) return i, err } const selectUploadsOfSite = `-- name: SelectUploadsOfSite :many SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE site_id = ? ORDER BY created_at DESC ` func (q *Queries) SelectUploadsOfSite(ctx context.Context, siteID int64) ([]Upload, error) { rows, err := q.db.QueryContext(ctx, selectUploadsOfSite, siteID) if err != nil { return nil, err } defer rows.Close() var items []Upload for rows.Next() { var i Upload if err := rows.Scan( &i.ID, &i.SiteID, &i.Guid, &i.MimeType, &i.Filename, &i.FileSize, &i.Slug, &i.Alt, &i.CreatedAt, ); 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 updateUpload = `-- name: UpdateUpload :exec UPDATE uploads SET alt = ? WHERE id = ? ` type UpdateUploadParams struct { Alt string ID int64 } func (q *Queries) UpdateUpload(ctx context.Context, arg UpdateUploadParams) error { _, err := q.db.ExecContext(ctx, updateUpload, arg.Alt, arg.ID) return err }