diff options
Diffstat (limited to 'source/api.js')
-rw-r--r-- | source/api.js | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/source/api.js b/source/api.js index 832114c..fdd9e22 100644 --- a/source/api.js +++ b/source/api.js @@ -42,7 +42,10 @@ var api = { storeName: "bookmarks", keyPath: 'id', autoIncrement: true, - dbVersion: 1, + dbVersion: 2, + indexes: [ + {name: "osisRef", keyPath: "osisRef", unique: true} + ], onStoreReady: function() { //console.log("isInitialized", self.isInitialized); self.isBmInitialized = true; @@ -66,7 +69,10 @@ var api = { storeName: "highlights", keyPath: 'id', autoIncrement: true, - dbVersion: 1, + dbVersion: 2, + indexes: [ + {name: "osisRef", keyPath: "osisRef", unique: true} + ], onStoreReady: function() { self.isHlInitialized = true; if(inCallback) inCallback(null, self.hlStore); @@ -89,7 +95,10 @@ var api = { storeName: "notes", keyPath: 'id', autoIncrement: true, - dbVersion: 1, + dbVersion: 2, + indexes: [ + {name: "osisRef", keyPath: "osisRef", unique: true} + ], onStoreReady: function() { self.isNoteInitialized = true; if(inCallback) inCallback(null, self.noteStore); @@ -232,6 +241,13 @@ var api = { ); }, + _query: function(inDB, inOptions, inCallback) { + //inOptions["onError"] = function (inError) {inCallback(inError);}; + inDB.query(function (inResults) { + inCallback(null, inResults); + }, inOptions); + }, + get: function (inId, inCallback) { this.wrapper(enyo.bind(this, function (inError, inDB) { if(!inError) this._get(inDB, inId, inCallback); @@ -255,7 +271,7 @@ var api = { getAllBookmarks: function (inCallback) { this.bmWrapper(enyo.bind(this, function (inError, inDB) { - if(!inError) this._getAll(inDB, inCallback); + if(!inError) this._query(inDB, {index: "osisRef"}, inCallback); else inCallback(inError); })); }, @@ -267,6 +283,13 @@ var api = { })); }, + getAllHighlights: function (inCallback) { + this.hlWrapper(enyo.bind(this, function (inError, inDB) { + if(!inError) this._query(inDB, {index: "osisRef"}, inCallback); + else inCallback(inError); + })); + }, + getNote: function (inId, inCallback) { this.noteWrapper(enyo.bind(this, function (inError, inDB) { if(!inError) this._get(inDB, inId, inCallback); @@ -281,6 +304,13 @@ var api = { })); }, + getAllNotes: function (inCallback) { + this.noteWrapper(enyo.bind(this, function (inError, inDB) { + if(!inError) this._query(inDB, {index: "osisRef"}, inCallback); + else inCallback(inError); + })); + }, + getUserData: function(inOsis, inVMax, inCallback) { var z=1, userData = {}; |