You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi ! I pasted a pretty simple example using transactions with two object stores. After creating the stores on the openIndexedDb() function, the code opens a Tx and add an object to one store (STORE_DB) and then tries to add other object to the other store (STORE_QUEUE). That lines fails due to there is a typo in the name of the key (it is declared as queueTime and the object to add has a property called queuedTime). The thing is that even when these statements are in a Tx, the first line is commit into the object store (STORE_DB). Why? anything wrong am I doing?
constDB_NAME="taskdb";constSTORE_DB="db1";constSTORE_QUEUE="queue";asyncfunctionopenIndexedDb(){returnawaitopenDB(DB_NAME,1,{upgrade(db){initializeDatabase(db);},});}functioninitializeDatabase(db){if(!db.objectStoreNames.contains(STORE_DB)){letdbStore=db.createObjectStore(STORE_DB,{keyPath: "id",});}if(!db.objectStoreNames.contains(STORE_QUEUE)){letqueueStore=db.createObjectStore(STORE_QUEUE,{keyPath: "queueTime",});}}letdb=awaitopenIndexedDb();consttx=db.transaction([STORE_DB,STORE_QUEUE],"readwrite");awaittx.objectStore(STORE_DB).add({id: 1123,bla: 1});//this worksawaittx.objectStore(STORE_QUEUE).add({queuedTime: Date.now(),id: 11});//this fails, but the previous line gets committed !awaittx.done;
The text was updated successfully, but these errors were encountered:
Hi ! I pasted a pretty simple example using transactions with two object stores. After creating the stores on the openIndexedDb() function, the code opens a Tx and add an object to one store (STORE_DB) and then tries to add other object to the other store (STORE_QUEUE). That lines fails due to there is a typo in the name of the key (it is declared as
queueTime
and the object to add has a property calledqueuedTime
). The thing is that even when these statements are in a Tx, the first line is commit into the object store (STORE_DB). Why? anything wrong am I doing?The text was updated successfully, but these errors were encountered: