TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt
Use this file to discover all available pages before exploring further.
properties table stores every real estate listing published through the Estructuras platform. Each record captures the full physical and commercial profile of a property — its location, pricing, physical attributes, listing status, and a reference back to the user who created it. The PropiertyModel class provides static async methods that cover the four main read patterns (all, by ID, by status, by type) as well as record creation, with all SQL parameterized to prevent injection.
Database Fields
A universally unique identifier generated at creation time via Node.js’s built-in
randomUUID() from the node:crypto module. Serves as the primary key for the properties table.A short, human-readable title for the listing (e.g.
"Casa en Urbanización Los Pinos"). Must be a string; validated as required by the property schema.A free-form text description of the property. Optional in the Zod schema but strongly recommended for complete listings. Must be a string if provided.
The commercial availability status of the property. Must be one of the three allowed values:
"Venta", "Alquiler", or "Ambas". Any other value is rejected at the schema validation layer with a descriptive error message.The structural category of the property. Must be one of the four allowed values:
"Casa", "Apartamento", "Terreno", or "Comercial". Any other value is rejected at the schema validation layer.The street-level address of the property (e.g.
"Av. Libertador, Edificio Torre Norte, Piso 3").The city in which the property is located (e.g.
"Caracas").The state or province in which the property is located (e.g.
"Distrito Capital").The listing price. Must be a numeric value; no currency is enforced at the model level. For rental properties this represents the monthly rent; for sale properties the asking price.
The number of bedrooms. Optional; must be a number if provided.
The number of bathrooms. Optional; must be a number if provided.
The total area of the property in square feet. Optional; must be a number if provided.
The number of dedicated parking spaces. Optional; must be a number if provided.
A URL pointing to the primary image for the listing (e.g. a cloud storage URL). Optional; not enforced in the current Zod schema but used during INSERT.
Foreign key referencing the
id of the user who created the listing. Populated automatically from the authenticated session context (userId) when PropiertyModel.register() is called — it is never supplied directly by the client request body.Enum Values
status — Listing availability
| Value | Meaning |
|---|---|
Venta | The property is listed for sale only. |
Alquiler | The property is listed for rent only. |
Ambas | The property is available for both sale and rent. |
property_type — Structural category
| Value | Meaning |
|---|---|
Casa | A standalone house or residential dwelling. |
Apartamento | A unit within a multi-floor apartment building. |
Terreno | An undeveloped land parcel or lot. |
Comercial | A commercial space (office, storefront, warehouse, etc.). |
Both enums are defined in
src/schemas/property.schema.js and enforced via Zod’s z.enum(). Submitting an unlisted value returns a human-readable Spanish error message that lists every valid option.Validation Rules
All incoming property data is validated through a Zod schema defined insrc/schemas/property.schema.js. validateProperty enforces all fields; validatePartialProperty wraps the same schema with .partial() for partial-update use cases.
Model Methods
All methods are static async members of thePropiertyModel class exported from src/models/property.model.js. The database client is the Turso libSQL client imported from src/db.js.
PropiertyModel.getAll()
Returns every property row in the table.
Throws:
"No hay propiedades" if the properties table contains no records.
PropiertyModel.getById(id)
Returns a single property row matching the given UUID.
| Parameter | Type | Description |
|---|---|---|
id | string | UUID of the property to retrieve |
Throws:
"Propiedad no encontrada en la base de datos" if no record matches the given id.
PropiertyModel.getByStatus(status)
Returns all properties whose status column matches the given value.
| Parameter | Type | Allowed values |
|---|---|---|
status | string | "Venta", "Alquiler", "Ambas" |
Throws:
"No existen propiedades con este Estado" if no listings have that status.
PropiertyModel.getByType(type)
Returns all properties whose property_type column matches the given value.
| Parameter | Type | Allowed values |
|---|---|---|
type | string | "Casa", "Apartamento", "Terreno", "Comercial" |
Throws:
"No hay propiedades de este tipo" if no listings have that property type.
PropiertyModel.register(data)
Inserts a new property listing into the database. The id is generated server-side; the user_id is taken from the authenticated session context rather than the request body.
| Parameter | Type | Required | Description |
|---|---|---|---|
data.title | string | Yes | Listing title |
data.description | string | No | Free-form description |
data.status | string | Yes | One of the three allowed status enum values |
data.property_type | string | Yes | One of the four allowed type enum values |
data.address | string | Yes | Street-level address |
data.city | string | Yes | City name |
data.state | string | Yes | State or province name |
data.price | number | Yes | Listing price or monthly rent |
data.bedrooms | number | No | Number of bedrooms |
data.bathrooms | number | No | Number of bathrooms |
data.square_feet | number | No | Total area in square feet |
data.parking_lots | number | No | Number of parking spaces |
data.img_url | string | No | URL of the primary listing image |
data.userId | string | Yes | UUID of the authenticated user — set by the controller |
Throws:
"Error al registrar la Propiedad: <db error>" if the INSERT fails.
Example Property Object
The following JSON represents a fully populated property record as it would be returned fromPropiertyModel.getById() or any other read method: