fetch_headline_children_recurse

Function fetch_headline_children_recurse 

Source
pub async fn fetch_headline_children_recurse(
    conn: &mut SqliteConnection,
    headline_id: i64,
) -> Result<Option<HeadlineChildren>, Error>
Expand description

再帰的に見出しアイテムの子孫を取得します。

WITH RECURSIVE children(p_id) AS (VALUES (?)
                                 UNION ALL
                                 SELECT headlines.id
                                 FROM headlines
                                          LEFT OUTER JOIN children ON headlines.parent_id = children.p_id
                                 WHERE headlines.parent_id = p_id)
SELECT *
FROM headlines
WHERE id IN (SELECT * FROM children)
ORDER BY parent_id, headline_pos NULLS LAST;