Skip to main content
This endpoint builds and executes a UPDATE … SET … WHERE statement against the specified PostgreSQL table. The columns to update and their new values come from the JSON request body; the row(s) to target are identified by the :property and :value URL path parameters. Both PUT and PATCH are mapped to the same controller (update_data) and behave identically — use whichever best matches your client’s semantic intent. The updated row is returned via RETURNING *.

Endpoints

Both methods accept the same path parameters and request body.

Path Parameters

string
required
Name of the PostgreSQL table to update. Example: customer, products.
string
required
Column name used in the WHERE clause to identify which row(s) to update. Typically a primary key column such as id.
string
required
The value that :property must equal for a row to be updated. This is passed as a URL segment and interpolated into the SQL as a string literal: WHERE {property} = '{value}'.

Request Body

Send a JSON object containing only the columns you want to change. The controller calls generate_str_of_dict(data) (with key_value = true, the default) to build the SET clause:
  • String values → column = 'new value'
  • Number values → column = 42
The resulting SQL executed against PostgreSQL is:
string | number
Any column that exists in the target table. Include only the fields you want to modify. Example: { "names": "New Name", "email": "[email protected]" }.

Responses

200 — OK

Returned when at least one row was updated (rowCount > 0).
number
Always 200 on success.
string
"Datos actualizados"
object
The full row after the update, as returned by RETURNING *. Contains all column values — not only the ones that were changed.

404 — Not Found

Returned when rowCount === 0, meaning no rows matched the WHERE condition.

500 — Internal Server Error

Returned on any exception thrown by the pg driver (constraint violation, unknown column, connection error, etc.).
object
Raw error from the pg driver. Check error.code and error.detail for PostgreSQL-level diagnostics.

Examples

Example Response — PATCH /update-data/customer/id/42


SQL injection risk. The :value path segment is interpolated verbatim into the SQL WHERE clause as a string literal (WHERE {property} = '{value}'). A malicious caller can craft a URL such as /update-data/customer/id/0' OR '1'='1 to match unintended rows. Sanitize and validate all path parameters — or switch to parameterised queries ($1, $2, …) — before exposing this endpoint in production.