axemclion / jquery-indexeddb

An IndexedDB Plugin for Jquery.
Other
195 stars 71 forks source link

transaction close immediately #30

Closed steeeveb closed 11 years ago

steeeveb commented 11 years ago

Hi, I'm trying do download chuncked data from server and add them to indexeddb inside a single transaction. How can I avoid that the transaction finishes before all my data are downloaded? I know I can't return a deferred(es. the one returned by $.ajax()) from progress callback. I'm missing something of your API? or this task is not possible?

thanks

axemclion commented 11 years ago

Ideally transactions should not be open for very long times as they would block other write transactions. Are you having problems with writing it using multiple transactions ?

steeeveb commented 11 years ago

I read about it..It's not your problem, indexeddb specs are clear for me now.

What I'm trying to accomplish is: 1 - open transaction 2 - download a page of json data 3 - add to indexeddb 4 - get another page and so on ... and finally close the transaction. But obviously I have a premature transaction autocommit(as progress doesn't wait for returned promises) I have a lot of data and I want to be able to replace the db with the updated version without loosing old data if something goes wrong. Maybe I can use some auxiliary objectStores and switch to them only when I'm sure that all new data are inserted. What do you think? this kind of transaction doesn't seem to be projected for what I want to obtain..