api.stays_explore_view
Description
List moorages notes order by stays
Table Definition
CREATE VIEW stays_explore_view AS (
SELECT s.id AS stay_id,
m.id AS moorage_id,
m.name AS moorage_name,
s.name AS stay_name,
s.arrived,
s.stay_code,
s.latitude,
s.longitude,
s.notes AS stay_notes,
m.notes AS moorage_notes,
CASE
WHEN (jsonb_array_length((s.user_data -> 'images'::text)) > 0) THEN true
ELSE false
END AS has_images,
(s.user_data -> 'images'::text) AS images,
s.id,
s.name
FROM (api.stays s
LEFT JOIN api.moorages m ON ((s.moorage_id = m.id)))
ORDER BY s.arrived DESC
)
Columns
| Name | Type | Default | Nullable |
|---|---|---|---|
| arrived | timestamp with time zone | true | |
| has_images | boolean | true | |
| id | integer | true | |
| images | jsonb | true | |
| latitude | double precision | true | |
| longitude | double precision | true | |
| moorage_id | integer | true | |
| moorage_name | text | true | |
| moorage_notes | text | true | |
| name | text | true | |
| stay_code | integer | true | |
| stay_id | integer | true | |
| stay_name | text | true | |
| stay_notes | text | true |
Referenced Tables
| Name | Columns | Comment | Type |
|---|---|---|---|
| api.stays | 15 | The stays table records time spent at moorages. Each stay links a moorage with arrival/departure timestamps. RLS policies filter by vessel_id. | BASE TABLE |
| api.moorages | 14 | The moorages table stores locations where vessels can stay (marinas, anchorages, etc.). Each moorage has geographic coordinates and metadata. | BASE TABLE |
Relations
erDiagram
"api.stays_explore_view" {
timestamp_with_time_zone arrived ""
boolean has_images ""
integer id ""
jsonb images ""
double_precision latitude ""
double_precision longitude ""
integer moorage_id ""
text moorage_name ""
text moorage_notes ""
text name ""
integer stay_code ""
integer stay_id ""
text stay_name ""
text stay_notes ""
}
Generated by tbls