title: Update indexedDB
body: <p>Hi I am trying to update records indexdb. I want to implement a generic method that allows me to upgrade to any field.</p>
  
  <p>To do this I have a function that returns me the record I need.</p>
  
  <pre><code>function getObjectStoreClienteDB(clave,valor){
      //Ahora recogeremos los datos de nuestro almacén &amp;quot;Productos&amp;quot;
      var transaction = db.transaction(["customers"], "readwrite");
      var objectStore = transaction.objectStore("customers");
  
      var index = objectStore.index(clave);
      var singleKeyRange = IDBKeyRange.only(valor);
  
      // To use one of the key ranges, pass it in as the first argument of openCursor()/openKeyCursor()
  
      return  index.openCursor(singleKeyRange);
  } 
  </code></pre>
  
  <p>And another that updates the returned record</p>
  
  <pre><code>function updateClienteDB(clave,valor,newvalor){
      console.log("updateClienteDB ... clave: "+clave+" valor: "+valor+" newvalor: "+newvalor);
      var objectStore = db.transaction(["customers"], "readwrite").objectStore("customers");
  
      request = getObjectStoreClienteDB("name",valor);
  
      request.onsuccess = function(event) {
        // Get the old value that we want to update
        var data = request.result;
  
        // update the value(s) in the object that you want to change
        if(clave=="name")
          data.name = newvalor;
         else if(clave=="email")
          data.email = newvalor;
         else if(clave=="matricula")
          data.matricula = newvalor;
         else if(clave=="telefono")
          data.telefono = newvalor;
  
        // Put this updated object back into the database.
        var requestUpdate = objectStore.put(data);
         requestUpdate.onerror = function(event) {
            console.log("addCliente ..."+name+" "+email +" "+ event.target.errorCode);
         };
         requestUpdate.onsuccess = function(event) {
              console.log("All done!");
         };
      };
  }
  </code></pre>
  
  <p>In the line:
  var requestUpdate = objectStore.put(data);</p>
  
  <p>error:
  Uncaught TransactionInactiveError: Failed to execute 'put' on 'IDBObjectStore': The transaction has finished.</p>