in public/dexie.js [2017:2059]
function tempTransaction(mode, storeNames, fn) {
if (!openComplete && !PSD.letThrough) {
if (!isBeingOpened) {
if (!autoOpen) return rejection(new exceptions.DatabaseClosed());
db.open().catch(nop); // Open in background. If if fails, it will be catched by the final promise anyway.
}
return dbReadyPromise.then(function () {
return tempTransaction(mode, storeNames, fn);
});
} else {
var trans = db._createTransaction(mode, storeNames, globalSchema);
try {
trans.create();
} catch (ex) {
return rejection(ex);
}
return trans
._promise(mode, function (resolve, reject) {
return newScope(function () {
PSD.trans = trans;
return fn(resolve, reject, trans);
});
})
.then(function (result) {
// Instead of resolving value directly, wait with resolving it until transaction has completed.
// Otherwise the data would not be in the DB if requesting it in the then() operation.
// Specifically, to ensure that the following expression will work:
//
// db.friends.put({name: "Arne"}).then(function () {
// db.friends.where("name").equals("Arne").count(function(count) {
// assert (count === 1);
// });
// });
//
return trans._completion.then(function () {
return result;
});
}); /*.catch(err => { // Don't do this as of now. If would affect bulk- and modify methods in a way that could be more intuitive. But wait! Maybe change in next major.
trans._reject(err);
return rejection(err);
});*/
}
}