Hello all
I would like to manage categories for a shop application. Each category can have subcategories, which in turn can have subcategories.
Currently I have modelled the categories collection to hold main categories in a document and all subcategories within a hierarchical structure.
{
categoryId: "127642744377643170",
name: "Schmuck",
description: "Selber gemachter Schmuck",
slug: "jewellery",
categories: [
{
categoryId: "644900134728228400",
name: "Fimo Schmuck",
description: "Kreative Ideen mit Fimo",
slug: "fimo",
categories: [
{
categoryId: "149824833816995330",
name: "Ohrringe",
description: "Ohrringe aus Fimo",
slug: "earrings",
categories: []
}
]
}
]
}
The current structure is practical for managing categories.
But if I want to get a single sub-category, it is not easy because I don’t know how to read out a sub-category directly.
It would be easier if the individual categories were saved in a separate document.
I therefore have the following questions:
-
What is the best way to model hierarchical structures with Fauna?
-
If I leave the structure as above, is there a way to be able to query subcategories directly? With a function / index? The query would have to read out the hierarchical structure recursively. What would such a query with fql v10 look like?
Thank you for the support