Managing Hierarchical Data in Xano

Options
I would like to create a category tree with nested subs and try to figure it out. 
any tips and tricks on how to achieve it in XANO?

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    can you give an example of what your database schema would look like? I'm not entirely following the question.

    Are you talking about mutli-level categories?
  • jasem al neaimi
    Options

    I think I figured it out
    First I created a category table
    [99504618-5326-47E7-B8FA-51D27C460283]
    With parent column to reference to the id of the category above

    In the example I have 4 categories all 3 are referencing to one


    Then I created an addone that will list products by category

    [5BDCA406-7009-48FB-9310-CD935B0F0507]
    Then I joint it with the category table
    [C5ACCCCA-A2D3-4E42-9045-1F482110D32A]

    With the where condition above to list all products under the tree of the selected category

    Then I created a get api endpoint for categories
    [67306C74-47BD-4C0A-B885-ABBC514E45D9]
    And added the custom addone I created above

    And then added a query condition

    [102846B8-4A97-4672-B533-893BE8E03EB0]


    With that if I select the top of the tree I get all the products under the tree and so on.


    Now is this the right way to create a category tree for a products table or there is a better way?
  • jasem al neaimi
    Options

    the output is wrong. When I call the parent level it’s giving me all
    But if I call the base level it’s good
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    can you come to office hours? Seems like you are close but it's hard to debug over this forum.
  • jasem al neaimi
    Options

    noted will do
    Thanks