title: How do I delete all records in IndexedDB
body: <p>I have an IndexedDB where I store all cart orders. On checkout, the cart needs to be clear. I'm trying to loop through each order and delete, but somehow, only the first order gets deleted. Here is my code:</p>
  
  <pre><code>const clear_cart = () =&gt; {
      let objectCart = db.transaction('cart').objectStore('cart');
  
      objectCart.openCursor().onsuccess = function(e){
          let cursor = e.target.result;
          if(cursor){
             let cartId = cursor.value.id;
  
             let transaction = db.transaction(['cart'], 'readwrite');
             let objectToDelete = transaction.objectStore('cart');
             let request = objectCart.objectToDelete(cartId);
  
             transaction.oncomplete = () =&gt; {
                  console.log(`cart ${cartId} is deleted!`);
             }
  
             cursor.continue();
          }
      }
  }
  </code></pre>