Skip to content

Commit 00745f5

Browse files
committed
Prefer vanilla indexeddb over the webkit flavor and other Safari-related tweaks.
1 parent caf26fd commit 00745f5

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

jSQL.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* jSQL.js v1.2
2+
* jSQL.js v1.3
33
* A Javascript Query Language Database Engine
44
* @author Robert Parham
55
* @website https://github.com/Pamblam/jSQL#jsql
@@ -1589,8 +1589,8 @@
15891589

15901590
try {
15911591
indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB;
1592-
IDBTransaction = window.hasOwnProperty('webkitIndexedDB') ? window.webkitIDBTransaction : window.IDBTransaction;
1593-
IDBKeyRange = window.hasOwnProperty('webkitIndexedDB') ? window.webkitIDBKeyRange : window.IDBKeyRange;
1592+
IDBTransaction = window.hasOwnProperty('IDBTransaction') ? window.IDBTransaction : window.webkitIDBTransaction ;
1593+
IDBKeyRange = window.hasOwnProperty('IDBKeyRange') ? window.IDBKeyRange : window.webkitIndexedDB;
15941594
} catch (e) {
15951595
throw "indexedDB is not supported in this browser";
15961596
}
@@ -1665,8 +1665,7 @@
16651665
// Insert a group of rows
16661666
self.insert = function(model, data, successCallback) {
16671667
if(typeof successCallback !== "function") successCallback = function(){};
1668-
var transParam = undefined === IDBTransaction ? 'readwrite' : IDBTransaction.READ_WRITE;
1669-
var transaction = self.db.transaction([model], transParam);
1668+
var transaction = self.db.transaction([model], undefined === IDBTransaction.READ_WRITE ? 'readwrite' : IDBTransaction.READ_WRITE);
16701669
var store, i, request;
16711670
var total = data.length;
16721671

@@ -1688,9 +1687,8 @@
16881687

16891688
// Delete all items from the database
16901689
self.delete = function(model, successCallback) {
1691-
var transParam = undefined === IDBTransaction ? 'readwrite' : IDBTransaction.READ_WRITE;
1692-
if(typeof successCallback !== "function") successCallback = function(){};
1693-
var transaction = self.db.transaction([model], transParam), store, request;
1690+
if(typeof successCallback != "function") successCallback = function(){};
1691+
var transaction = self.db.transaction([model], undefined === IDBTransaction.READ_WRITE ? 'readwrite' : IDBTransaction.READ_WRITE), store, request;
16941692
transaction.onerror = function(){ throw "Could not initiate a transaction"; };;
16951693
store = transaction.objectStore(model);
16961694
request = store.clear();
@@ -1701,8 +1699,7 @@
17011699
// Get all data from the datastore
17021700
self.select = function(model, successCallback) {
17031701
if("function" !== typeof successCallback) successCallback = function(){};
1704-
var transParam = undefined === IDBTransaction ? 'readonly' : IDBTransaction.READ_ONLY ;
1705-
var transaction = self.db.transaction([model], transParam), store, request, results = [];
1702+
var transaction = self.db.transaction([model], undefined === IDBTransaction.READ_ONLY ? 'readonly' : IDBTransaction.READ_ONLY), store, request, results = [];
17061703
transaction.onerror = function(){ throw "Could not initiate a transaction"; };;
17071704
store = transaction.objectStore(model);
17081705
request = store.openCursor();
@@ -1899,7 +1896,7 @@
18991896
////////////////////////////////////////////////////////////////////////////
19001897

19011898
return {
1902-
version: 1.2,
1899+
version: 1.3,
19031900
tables: {},
19041901
query: jSQLParseQuery,
19051902
createTable: createTable,

0 commit comments

Comments
 (0)