16 lines
600 B
SQL
16 lines
600 B
SQL
SELECT
|
|
x.id AS id,
|
|
JSON_AGG(x.name) AS name,
|
|
JSON_AGG(x.hue) AS hue,
|
|
JSON_AGG(x.access_public) AS access_public,
|
|
JSON_AGG(x.access_level_default) AS access_level_default,
|
|
JSON_AGG(y1.level) AS access_level_attributed_group,
|
|
JSON_AGG(y2.level) AS access_level_attributed_user
|
|
FROM
|
|
calendars AS x
|
|
LEFT OUTER JOIN calendar_access_attributed_group AS y1 ON ((x.id = y1.calendar_id) AND (y1.group_id IN (SELECT group_id FROM user_groups WHERE (user_id = $user_id))))
|
|
LEFT OUTER JOIN calendar_access_attributed_user AS y2 ON ((x.id = y2.calendar_id) AND (y2.user_id = $user_id))
|
|
GROUP BY
|
|
x.id
|
|
;
|