Creating TREE of categories and subcategories
Hello guys
Am creating a tree of categories
for my application. There is no limit (infinite) to the depth of subcategories that can be created.
Somewhat like this:
My CategorySchema looks like this
schema: {
_id : String,
name: String,
children: [] // will contain subcats in form of {_id:String, name: String, children: []}
}
MY PROBLEM
I want a dynamic solution/mongodb-query/mongoose-query to CREATE the tree of categories. I am new to mongodb, I could'nt find relevant problem-solution on the web, hence seeing help.
Have already spent quite a lot of time trying by myself. Please help me with any (but should be efficient) solution to my poblem.
Thanks in advance
