We are using the Facebook IndexedDB Polyfill to allow the IndexedDB API to be utilised in Safari/ Mobile Safari. However, we are experiencing a "TransactionInactiveError" when attempting to update records - the error originates from line 1567 of the Polyfill.js file: if (!me._active) throw new util.error("TransactionInactiveError");
Here's a quick example I've put together. Simply add the Facebook Polyfill script tag reference and run in Safari:
var db;
var request = indexedDB.open("polyfillTest");
request.onupgradeneeded = function () {
// The database did not previously exist, so create object stores and indexes.
db = request.result;
var store = db.createObjectStore("books", {keyPath: "isbn"});
var titleIndex = store.createIndex("by_title", "title", {unique: true});
var authorIndex = store.createIndex("by_author", "author");
// Populate with initial data.
store.put({title: "Quarry Memories", author: "Fred", isbn: 123456});
store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567});
store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678});
updateItem(store);
};
request.onsuccess = function () {
db = request.result;
};
function updateItem(store) {
var request = store.get(123456);
request.onsuccess = function () {
var book = request.result;
book.title = "New Title";
book.author = "New Author";
var updateRequest = store.put(book);
updateRequest.onsuccess = function (evt) {
console.log("Book updated successfully.");
};
updateRequest.onerror = function (evt) {
console.error("Book could not be updated.");
};
};
}
Any help appreciated!
Many thanks