This endpoint accepts a raw SQL string in the request body and executes it directly against the PostgreSQL database viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/factus_challenge/llms.txt
Use this file to discover all available pages before exploring further.
db.query(body.query). It exists to support use-cases that the other generic CRUD endpoints cannot handle — most importantly JOIN queries that span multiple tables, and targeted lookups by non-primary-key columns. In the reference implementation, the frontend uses this endpoint to resolve a product by code_reference and to fetch a single customer by id when assembling an invoice payload.
Endpoint
Request Body
The complete, valid SQL query to execute. The string is passed directly to the
pg driver with no preprocessing, parameterisation, or sanitisation.Responses
200 — OK
Returned when at least one row is found (rowCount > 0).
Always
200 on success."Datos encontrados"Array of row objects returned by PostgreSQL. The shape of each object depends entirely on the columns selected by the SQL query.
404 — Not Found
Returned whenrowCount === 0 — the query executed without error but returned no rows.
500 — Internal Server Error
Returned when thepg driver throws an exception (syntax error in the SQL, missing table, connection failure, etc.).
Raw error from the
pg driver. Check error.code and error.message for PostgreSQL diagnostics.How the Frontend Uses This Endpoint
The reference frontend makes two specific calls to/get-join when building an invoice payload:
-
Look up a product by
code_reference— after the user enters or scans a product code, the frontend resolves the full product record: -
Look up a customer by
id— to attach complete customer details to the invoice:
data array, and the frontend picks data[0] for the single-result case.
Examples
Example Response — JOIN query
In the reference implementation, the frontend uses
/get-join for exactly two purposes: resolving a single product record by code_reference and resolving a single customer record by id when constructing an invoice payload before submission to the Factus billing API. All other data fetching goes through the safer GET /get-data/:table endpoint.