When you open your transaction on the data
object store, you're opening it as readonly
:
var transaction = db.transaction(["data"], "readonly");
var objectStore = transaction.objectStore("data");
I believe you're looking for readwrite
. readonly
transaction mode should never be allowed to remove objects. The versionchange
transaction can do both, but should probably only be used when actually modifying a database schema and not overloaded to also insert entries.
One tip: Leave the initial tx as readonly
and open a new one for the object removal. Reusing transactions, it's easy to run into headaches when transactions start committing without your explicit doing so.