How do I get an object from this tree? :
{
"_id" : ObjectId("33b97aa654bce61322002559"),
"name" : "Test",
"children" : [
"_id" : ObjectId("44b97aa654bce61322002559"),
"name" : "Test Children",
"children" : [
"_id" : ObjectId("55b97aa654bce61322002559"),
"name" : "Test Children Children",
"children" : "",
"products" : [
"_id" : ObjectId("55b97aa654bce61322002559"),
"name" : "Product 1" //I need this object
"attrib" : [
"sale" : 1,
"new" : 1,
"instock" : 1,
]
],
"products" : ""
]
],
"products" : ""
}
Levels can be any number.
- children
- -children
- --children
- ---children
-
----children
$arr = Categories::findOne(['_id' => '55b97aa654bce61322002559']); debug($arr);
Maybe I'm not shaping the structure db correctly? Thank you.