I can’t seem to get my head around this and how to get it working.
db ->
{
"_id": {
"_str": “571a3e9c089e6e731f2b4567”
},
“catid”: 1,
“category”: “parent”,
“children”: [
{
“catid”: 2,
“category”: “child1”
},
{
“catid”: 3,
“category”: “child3”
}
]
}
jsx ->
import React from ‘react’;
import TrackerReact from ‘meteor/ultimatejs:tracker-react’;
import { Categories } from ‘…/…/collections’;
export default class Categories extends TrackerReact(React.Component) {
categories() {
return Categories.find({}).fetch();
}
render() {
let cat = this.categories();
return (
<ul className="nav navbar-nav hidden-sm">
{cat.map(function(cat) {
return <li key={cat._id}>
<a href="#">{cat.category}</a>
<ul>
<li><a href="#">childrens...</a></li>
</ul>
</li>;
})}
</ul>
)
}
}
I’m trying to get an array like this
parent1
-child1
-child2
parent2
-child1
-child2