Accessing IndexedDB from multiple javascript threads

I think I found a work around for this for now. Not really as clean as I would like, but it seems to be thread safe.

I start by storing the datetime into a LastEdit field, whenever I update the data. From the web-worker, I am posting a message to the browser.

self.postMessage('UpdateDataSent#' + data.ID + '#' + data.LastEdit);

Then in the browser I am updating my sent flag, as long as the last edit date hasn't changed.

// Get the data from the DB in a transaction
if (data.LastEdit == lastEdit)
{
    data.Sent = true;
    var saveStore = trans.objectStore("Data");
    var saveRequest = saveStore.put(data);
    console.log('Data updated to Sent');
}

Since this is all done in a transaction in the browser side, it seems to work fine. Once the browsers support the Sync API I can throw it all away anyway.