MCPcopy
hub / github.com/alyssaxuu/motionity / createTransaction

Function createTransaction

src/js/libraries/localbase.js:1761–1789  ·  view source on GitHub ↗
(dbInfo, mode, callback, retries)

Source from the content-addressed store, hash-verified

1759// FF doesn't like Promises (micro-tasks) and IDDB store operations,
1760// so we have to do it with callbacks
1761function createTransaction(dbInfo, mode, callback, retries) {
1762 if (retries === undefined) {
1763 retries = 1;
1764 }
1765
1766 try {
1767 var tx = dbInfo.db.transaction(dbInfo.storeName, mode);
1768 callback(null, tx);
1769 } catch (err) {
1770 if (retries > 0 && (!dbInfo.db || err.name === 'InvalidStateError' || err.name === 'NotFoundError')) {
1771 return Promise$1.resolve().then(function () {
1772 if (!dbInfo.db || err.name === 'NotFoundError' && !dbInfo.db.objectStoreNames.contains(dbInfo.storeName) && dbInfo.version <= dbInfo.db.version) {
1773 // increase the db version, to create the new ObjectStore
1774 if (dbInfo.db) {
1775 dbInfo.version = dbInfo.db.version + 1;
1776 }
1777 // Reopen the database for upgrading.
1778 return _getUpgradedConnection(dbInfo);
1779 }
1780 }).then(function () {
1781 return _tryReconnect(dbInfo).then(function () {
1782 createTransaction(dbInfo, mode, callback, retries - 1);
1783 });
1784 })["catch"](callback);
1785 }
1786
1787 callback(err);
1788 }
1789}
1790
1791function createDbContext() {
1792 return {

Callers 8

getItemFunction · 0.85
iterateFunction · 0.85
setItemFunction · 0.85
removeItemFunction · 0.85
clearFunction · 0.85
lengthFunction · 0.85
keyFunction · 0.85
keysFunction · 0.85

Calls 2

_getUpgradedConnectionFunction · 0.85
_tryReconnectFunction · 0.85

Tested by

no test coverage detected