title: How to update an IndexedDB item with autoincrement key?
body: <p>I created an object store with autoIncrement: <code>db.createObjectStore(&quot;items&quot;, {autoIncrement:true});</code></p>
  <p>Now I want to be able to update an item given its key and a new value, so I wrote this function:</p>
  <pre><code>let updateItem = (key, newData) =&gt; {
      let objectStore = db.transaction([&quot;items&quot;], &quot;readwrite&quot;).objectStore(&quot;items&quot;);
      let request = objectStore.get(key);
      request.onsuccess = (e) =&gt; {
          let data = e.target.result;
          Object.assign(data, newData);
          let requestUpdate = objectStore.put(data);      
      };
  }
  </code></pre>
  <p>However, instead of updating the value, it creates a new item with the new data. I think it makes sense since <code>e.target.result</code> does not contain any information about its key. So how do I update an element in such an object store?</p>