title: How can I convert an SQL primary key in JSON to a javascript object key with the other data as it's value
body: <p>Whenever I read all my data from a database table and receive it as JSON from my API, I get my data like this (<code>unique_name</code> being the primary key in this example):</p>
  <pre class="lang-json prettyprint-override"><code>[{&quot;unique_name&quot;:&quot;alice&quot;, &quot;age&quot;:18, &quot;city&quot;:&quot;kansas&quot;},{&quot;unique_name&quot;:&quot;bob&quot;, &quot;age&quot;:20, &quot;city&quot;:&quot;chicago&quot;}]
  </code></pre>
  <p>In my javascript application, however, I need my data to be formatted like so:</p>
  <pre class="lang-js prettyprint-override"><code>const myData = {alice: {age:18, city:&quot;kansas&quot;}, bob: {age:20, city:&quot;chicago&quot;}}
  </code></pre>
  <p>I guess this could be done with object mapping of some sort, but I'm afraid this would be too slow with a lot of entries. Is there any clean way to do this?</p>