title: How to build a list of composite objects with Express/MySQL?
body: <p>I am following a tutorial which only has a simple object model:</p>
  <pre><code>Customer.getAll = result =&gt; {
    sql.query(&quot;SELECT * FROM customers&quot;, (err, res) =&gt; {
      if (err) {
        console.log(&quot;error: &quot;, err);
        result(null, err);
        return;
      }
  
      console.log(&quot;customers: &quot;, res);
      result(null, res);
    });
  };
  </code></pre>
  <p>However, I have want my objects to include parent table with child table included. I haven't found a good example of how to accomplish this. Can anyone point me to some good resources on this?</p>
  <p>I'd want to return something like:</p>
  <pre><code>[
    {
      &quot;id&quot;: 1,
      &quot;name&quot;: &quot;Something&quot;,
      &quot;type&quot;: 1,
      &quot;Values&quot;: [
        { &quot;type&quot;: &quot;A&quot;, &quot;value1&quot;: 20, &quot;Value2&quot;: 40, &quot;Value3&quot;: 0 },
        { &quot;type&quot;: &quot;B&quot;, &quot;value1&quot;: 100, &quot;Value2&quot;: 40, &quot;Value3&quot;: 0 },
        { &quot;type&quot;: &quot;C&quot;, &quot;value1&quot;: 0, &quot;Value2&quot;: 40, &quot;Value3&quot;: 30 }
      ]
    }
  ]
  </code></pre>
  <p>Where the parent table might be Item, and has a child table called ItemValues. How do I build objects that look like this.</p>