Dev Helpers
← Back

Build a hierarchy path

Build a hierarchy path using SQLite.

Open this example in the interactive library

Source code

WITH RECURSIVE edges(p,c) AS (VALUES('a','b'),('b','c')), walk(n,path) AS (VALUES('a','a') UNION ALL SELECT c,path||'/'||c FROM edges JOIN walk ON p=n) SELECT path FROM walk;

Sample output

[
  {
    "path": "a"
  },
  {
    "path": "a/b"
  },
  {
    "path": "a/b/c"
  }
]