// 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 interface{}) error { _, err := q.db.ExecContext(ctx, deleteUpload, id) return err } const insertUpload = `-- name: InsertUpload :exec INSERT INTO uploads ( site_id, guid, mime_type, filename, created_at, alt ) VALUES (?, ?, ?, ?, ?, ?) RETURNING id ` type InsertUploadParams struct { SiteID int64 Guid string MimeType string Filename string CreatedAt int64 Alt string } 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.CreatedAt, arg.Alt, ) return err } const selectUploadByID = `-- name: SelectUploadByID :one SELECT id, site_id, guid, mime_type, filename, file_size, alt, created_at FROM uploads WHERE id = ? ` func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (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.Alt, &i.CreatedAt, ) return i, err } const selectUploadsOfSite = `-- name: SelectUploadsOfSite :many SELECT id, site_id, guid, mime_type, filename, file_size, 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.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 interface{} } func (q *Queries) UpdateUpload(ctx context.Context, arg UpdateUploadParams) error { _, err := q.db.ExecContext(ctx, updateUpload, arg.Alt, arg.ID) return err }