Skip to content

Commit

Permalink
- Optimize: use WebSQL readTransaction when in readonly mode
Browse files Browse the repository at this point in the history
- Feature: Add `shimIndexedDB.__getConfig()`
  • Loading branch information
brettz9 committed Oct 27, 2016
1 parent 6594419 commit 09b4a75
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 22 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Expand Up @@ -246,7 +246,8 @@
- Feature: Add ".sqlite" extension to database name for sake of (Windows)
file type identification
- Feature: Expose `__setConfig(prop, val)` method for setting pseudo-global
property used internally for config.
property used internally for config and `shimIndexedDB.__getConfig()`
to read
- Feature: Expose `__setUnicodeIdentifiers()` for setting Unicode
regular expression strings
- Feature: Implement `IDBTransaction.objectStoreNames`
Expand All @@ -263,6 +264,7 @@
yet treating bubbling or `preventDefault`); change `ShimEvent` to utilize
polyfill from `eventtarget`
- Repo files: Rename test folders for ease in distinguishing
- Optimize: use WebSQL `readTransaction` when in `readonly` mode
- Optimize: Avoid caching and other processing in `IDBCursor` multiEntry
finds (used by `IDBObjectStore` or `IDBIndex` `count` with key range)
- Refactoring (Avoid globals): Change from using window global to a CFG module
Expand Down
10 changes: 8 additions & 2 deletions README.md
Expand Up @@ -114,15 +114,21 @@ window.shimIndexedDB.__debug(true);
Rather than using globals, a method has been provided to share state across
IndexedDBShim modules.

Its signature:
Its signature for setting configuration:

```js
shimIndexedDB.__setConfig(property, value);
```

...and for retrieving:

```js
shimIndexedDB.__getConfig(property);
```

The available properties are:

- __DEBUG__ - Boolean (equivalent to `shimIndexedDB.__debug`)
- __DEBUG__ - Boolean (equivalent to calling `shimIndexedDB.__debug(val)`)
- __cursorPreloadPackSize__ - Number indicating how many records to preload for
caching of (non-multiEntry) `IDBCursor.continue` calls. Defaults to 100.
- __win__, Object on which there may be an `openDatabase` method (if any)
Expand Down
6 changes: 5 additions & 1 deletion dist/indexeddbshim-UnicodeIdentifiers-node.js
Expand Up @@ -19830,7 +19830,8 @@ IDBTransaction.prototype.__executeRequests = function () {
this.__running = true;
var me = this;

me.db.__db.transaction(function executeRequests(tx) {
me.db.__db[me.mode === 'readonly' ? 'readTransaction' : 'transaction']( // `readTransaction` is optimized, at least in `node-websql`
function executeRequests(tx) {
me.__tx = tx;
var q = null,
i = -1;
Expand Down Expand Up @@ -21644,6 +21645,9 @@ function setGlobalVars(idb) {
IDB.shimIndexedDB.__setConfig = function (prop, val) {
_CFG2.default[prop] = val;
};
IDB.shimIndexedDB.__getConfig = function (prop) {
return _CFG2.default[prop];
};
IDB.shimIndexedDB.__setUnicodeIdentifiers = function (ui) {
this.__setConfig('UnicodeIDStart', ui.UnicodeIDStart);
this.__setConfig('UnicodeIDContinue', ui.UnicodeIDContinue);
Expand Down
6 changes: 3 additions & 3 deletions dist/indexeddbshim-UnicodeIdentifiers-node.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/indexeddbshim-UnicodeIdentifiers.js
Expand Up @@ -12333,7 +12333,8 @@ IDBTransaction.prototype.__executeRequests = function () {
this.__running = true;
var me = this;

me.db.__db.transaction(function executeRequests(tx) {
me.db.__db[me.mode === 'readonly' ? 'readTransaction' : 'transaction']( // `readTransaction` is optimized, at least in `node-websql`
function executeRequests(tx) {
me.__tx = tx;
var q = null,
i = -1;
Expand Down Expand Up @@ -14140,6 +14141,9 @@ function setGlobalVars(idb) {
IDB.shimIndexedDB.__setConfig = function (prop, val) {
_CFG2.default[prop] = val;
};
IDB.shimIndexedDB.__getConfig = function (prop) {
return _CFG2.default[prop];
};
IDB.shimIndexedDB.__setUnicodeIdentifiers = function (ui) {
this.__setConfig('UnicodeIDStart', ui.UnicodeIDStart);
this.__setConfig('UnicodeIDContinue', ui.UnicodeIDContinue);
Expand Down
6 changes: 3 additions & 3 deletions dist/indexeddbshim-UnicodeIdentifiers.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/indexeddbshim-node.js
Expand Up @@ -19830,7 +19830,8 @@ IDBTransaction.prototype.__executeRequests = function () {
this.__running = true;
var me = this;

me.db.__db.transaction(function executeRequests(tx) {
me.db.__db[me.mode === 'readonly' ? 'readTransaction' : 'transaction']( // `readTransaction` is optimized, at least in `node-websql`
function executeRequests(tx) {
me.__tx = tx;
var q = null,
i = -1;
Expand Down Expand Up @@ -21613,6 +21614,9 @@ function setGlobalVars(idb) {
IDB.shimIndexedDB.__setConfig = function (prop, val) {
_CFG2.default[prop] = val;
};
IDB.shimIndexedDB.__getConfig = function (prop) {
return _CFG2.default[prop];
};
IDB.shimIndexedDB.__setUnicodeIdentifiers = function (ui) {
this.__setConfig('UnicodeIDStart', ui.UnicodeIDStart);
this.__setConfig('UnicodeIDContinue', ui.UnicodeIDContinue);
Expand Down
6 changes: 3 additions & 3 deletions dist/indexeddbshim-node.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/indexeddbshim-node.min.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/indexeddbshim.js
Expand Up @@ -12333,7 +12333,8 @@ IDBTransaction.prototype.__executeRequests = function () {
this.__running = true;
var me = this;

me.db.__db.transaction(function executeRequests(tx) {
me.db.__db[me.mode === 'readonly' ? 'readTransaction' : 'transaction']( // `readTransaction` is optimized, at least in `node-websql`
function executeRequests(tx) {
me.__tx = tx;
var q = null,
i = -1;
Expand Down Expand Up @@ -14107,6 +14108,9 @@ function setGlobalVars(idb) {
IDB.shimIndexedDB.__setConfig = function (prop, val) {
_CFG2.default[prop] = val;
};
IDB.shimIndexedDB.__getConfig = function (prop) {
return _CFG2.default[prop];
};
IDB.shimIndexedDB.__setUnicodeIdentifiers = function (ui) {
this.__setConfig('UnicodeIDStart', ui.UnicodeIDStart);
this.__setConfig('UnicodeIDContinue', ui.UnicodeIDContinue);
Expand Down
6 changes: 3 additions & 3 deletions dist/indexeddbshim.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/indexeddbshim.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/IDBTransaction.js
Expand Up @@ -44,7 +44,7 @@ IDBTransaction.prototype.__executeRequests = function () {
this.__running = true;
const me = this;

me.db.__db.transaction(
me.db.__db[me.mode === 'readonly' ? 'readTransaction' : 'transaction']( // `readTransaction` is optimized, at least in `node-websql`
function executeRequests (tx) {
me.__tx = tx;
let q = null, i = -1;
Expand Down
3 changes: 3 additions & 0 deletions src/setGlobalVars.js
Expand Up @@ -74,6 +74,9 @@ function setGlobalVars (idb) {
IDB.shimIndexedDB.__setConfig = function (prop, val) {
CFG[prop] = val;
};
IDB.shimIndexedDB.__getConfig = function (prop) {
return CFG[prop];
};
IDB.shimIndexedDB.__setUnicodeIdentifiers = function (ui) {
this.__setConfig('UnicodeIDStart', ui.UnicodeIDStart);
this.__setConfig('UnicodeIDContinue', ui.UnicodeIDContinue);
Expand Down

0 comments on commit 09b4a75

Please sign in to comment.