title: Deleting multiple records in IndexedDB based on index
body: <p>I am using IndexedDB and I have two object stores: <em>equip</em> (represents different equipment, primary key <em>tagNo</em>) and <em>equipParts</em> (represents the parts of a piece of equipment and has an index which is based on the tag number/serial number, primary key <em>seqNo</em>, with a field <em>tagNo</em> which represents the equipment that part is part of).</p>
  
  <p>If I delete a record in <em>equip</em>, I want to delete all records in <em>equipParts</em> bearing the <em>tagNo</em> of <em>equip</em> (just like "where equipParts.tagNo = equip.tagNo").</p>
  
  <p>Excerpt from my code:</p>
  
  <pre><code>var tx = db.transaction(["equip", "equipParts"],"readwrite");
  var estore = tx.objectStore("equip");
  var pstore = tx.objectStore("equipParts");
  var tagIndex = pstore.index("by_tagNo");
  var pdestroy = tagIndex.openCursor(IDBKeyRange.only(tagno)); //opens all records bearing the selected tag number
  pdestroy.onsuccess = function() {
      var cursor = pdestroy.result;
      if (cursor) {
          if (cursor.value.tagNo == tagno) {
              pstore.delete(cursor.value.seqNo); //I guess I'm wrong here
          }
          cursor.continue;
      }
  }
  pdestroy.onerror = function() {
      alert("Deletion attempt NG");
  }
  var ereq = estore.delete(tagno);
  ereq.onsuccess = function(e) {
      alert("Form deletion OK");
      window.location = "index.html";
  }
  ereq.onerror = function(e) {
      alert("Form deletion NG");
      window.location = "index.html";
  }
  db.close();
  </code></pre>
  
  <p>The problem is that only the record in <em>equip</em> is deleted; the records in <em>equipParts</em> stay there. Is there a way to delete multiple records in an IndexedDB object store based on a non-unique index (which can be the primary key of the parent object store)?</p>