Skip to content

Commit

Permalink
Fix: Provide refactoring for IndexedDBShim (issue #87).
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Apr 11, 2016
1 parent 79fe048 commit d40286f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
an `add()`
- Fix: Avoid adding `keyPath` property to `add`/`update` records if property
is already present;
- Fix: Provide refactoring for IndexedDBShim (issue #87).
- Validation: Tighter checking on argument to `modify` method (ensure is
an object) and on index creation objects (issue #149)
- Docs: Badges, CHANGES, clarify `add`, `update`, `delete`, `filter` and
Expand Down
8 changes: 4 additions & 4 deletions dist/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
return err;
};

var createSchema = function createSchema(e, schema, db, server, version) {
var createSchema = function createSchema(e, request, schema, db, server, version) {
if (!schema || schema.length === 0) {
return;
}
Expand All @@ -762,7 +762,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
// should be without risk in this loop
// `NotFoundError` - since we are iterating the dynamically updated
// `objectStoreNames`
e.currentTarget.transaction.db.deleteObjectStore(name);
db.deleteObjectStore(name);
}
}

Expand All @@ -771,7 +771,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
var table = schema[tableName];
var store = void 0;
if (db.objectStoreNames.contains(tableName)) {
store = e.currentTarget.transaction.objectStore(tableName); // Shouldn't throw
store = request.transaction.objectStore(tableName); // Shouldn't throw
} else {
// Errors for which we are not concerned and why:
// `InvalidStateError` - We are in the upgrade transaction.
Expand Down Expand Up @@ -874,7 +874,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
reject(e);
};
request.onupgradeneeded = function (e) {
var err = createSchema(e, schema, e.target.result, server, version);
var err = createSchema(e, request, schema, e.target.result, server, version);
if (err) {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/db.js.map

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@
return err;
};

const createSchema = function (e, schema, db, server, version) {
const createSchema = function (e, request, schema, db, server, version) {
if (!schema || schema.length === 0) {
return;
}
Expand All @@ -670,7 +670,7 @@
// should be without risk in this loop
// `NotFoundError` - since we are iterating the dynamically updated
// `objectStoreNames`
e.currentTarget.transaction.db.deleteObjectStore(name);
db.deleteObjectStore(name);
}
}

Expand All @@ -679,7 +679,7 @@
const table = schema[tableName];
let store;
if (db.objectStoreNames.contains(tableName)) {
store = e.currentTarget.transaction.objectStore(tableName); // Shouldn't throw
store = request.transaction.objectStore(tableName); // Shouldn't throw
} else {
// Errors for which we are not concerned and why:
// `InvalidStateError` - We are in the upgrade transaction.
Expand Down Expand Up @@ -778,7 +778,7 @@
reject(e);
};
request.onupgradeneeded = e => {
let err = createSchema(e, schema, e.target.result, server, version);
let err = createSchema(e, request, schema, e.target.result, server, version);
if (err) {
reject(err);
}
Expand Down

0 comments on commit d40286f

Please sign in to comment.