|
1 | 1 | /** |
2 | | - * jSQL.js v1.2 |
| 2 | + * jSQL.js v1.3 |
3 | 3 | * A Javascript Query Language Database Engine |
4 | 4 | * @author Robert Parham |
5 | 5 | * @website https://github.com/Pamblam/jSQL#jsql |
|
1589 | 1589 |
|
1590 | 1590 | try { |
1591 | 1591 | 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; |
1594 | 1594 | } catch (e) { |
1595 | 1595 | throw "indexedDB is not supported in this browser"; |
1596 | 1596 | } |
|
1665 | 1665 | // Insert a group of rows |
1666 | 1666 | self.insert = function(model, data, successCallback) { |
1667 | 1667 | 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); |
1670 | 1669 | var store, i, request; |
1671 | 1670 | var total = data.length; |
1672 | 1671 |
|
|
1688 | 1687 |
|
1689 | 1688 | // Delete all items from the database |
1690 | 1689 | 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; |
1694 | 1692 | transaction.onerror = function(){ throw "Could not initiate a transaction"; };; |
1695 | 1693 | store = transaction.objectStore(model); |
1696 | 1694 | request = store.clear(); |
|
1701 | 1699 | // Get all data from the datastore |
1702 | 1700 | self.select = function(model, successCallback) { |
1703 | 1701 | 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 = []; |
1706 | 1703 | transaction.onerror = function(){ throw "Could not initiate a transaction"; };; |
1707 | 1704 | store = transaction.objectStore(model); |
1708 | 1705 | request = store.openCursor(); |
|
1899 | 1896 | //////////////////////////////////////////////////////////////////////////// |
1900 | 1897 |
|
1901 | 1898 | return { |
1902 | | - version: 1.2, |
| 1899 | + version: 1.3, |
1903 | 1900 | tables: {}, |
1904 | 1901 | query: jSQLParseQuery, |
1905 | 1902 | createTable: createTable, |
|
0 commit comments