feat: Add PUT and PATCH datasets endpoints

This commit is contained in:
2026-07-21 00:19:52 +05:00
parent 47b2e8653d
commit 00a0cd1b8e
5 changed files with 451 additions and 4 deletions

View File

@@ -68,6 +68,23 @@ func (r *DatasetRepository) Create(ctx context.Context, d domain.Dataset) (domai
return out, mapError(err)
}
// UpdateFields overwrites a dataset's editable metadata columns (category,
// name, description, unit). description and unit are nullable: a nil pointer
// clears the column. Returns domain.ErrNotFound if the dataset does not
// exist, or domain.ErrConflict if categoryID does not reference an existing
// category.
func (r *DatasetRepository) UpdateFields(ctx context.Context, id, categoryID uuid.UUID, name string, description, unit *string) (domain.Dataset, error) {
row := r.pool.QueryRow(ctx,
`UPDATE datasets
SET category_id = $2, name = $3, description = $4, unit = $5, updated_at = now()
WHERE id = $1
RETURNING `+datasetColumns,
id, categoryID, name, description, unit,
)
out, err := scanDataset(row)
return out, mapError(err)
}
// MarkParsed stores the detected attribute columns and moves the dataset to
// awaiting_mapping, clearing any previous parse error.
func (r *DatasetRepository) MarkParsed(ctx context.Context, id uuid.UUID, cols []domain.AttributeColumn) error {