WIP: jIO storage to provide search indexing for storages without search functionality
-
added 2 commits
Toggle commit list -
Toggle commit list
-
added 2 commits
Toggle commit list -
added 2 commits
Toggle commit list -
test/jio.storage/liststorage.tests.js 0 → 100644
6 * option) any later version, as published by the Free Software Foundation. 7 * 8 * You can also Link and Combine this program with other software covered by 9 * the terms of any of the Free Software licenses or any of the Open Source 10 * Initiative approved licenses and Convey the resulting work. Corresponding 11 * source of such a combination shall include the source code for all other 12 * software used. 13 * 14 * This program is distributed WITHOUT ANY WARRANTY; without even the implied 15 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * See COPYING file for full licensing terms. 18 * See https://www.nexedi.com/licensing for rationale and options. 19 */ 20 /*jslint nomen: true */ 21 /*global Blob, indexedDB*/ -
test/jio.storage/liststorage.tests.js 0 → 100644
160 sub_storage: { 161 type: "dummystorage1" 162 } 163 }); 164 165 DummyStorage.prototype.post = function (param) { 166 deepEqual(param, {"name": "test_name"}); 167 return "posted"; 168 }; 169 170 jio.post({"name": "test_name"}) 171 .then(function (result) { 172 equal(result, "posted"); 173 jio.__storage._signature_storage.get("posted") 174 .then(function (result) { 175 equal(result.id, "posted"); -
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
test/jio.storage/indexstorage2.tests.js 0 → 100644
61 } 62 jIO.addStorage('dummystorage3', DummyStorage3); 63 64 ///////////////////////////////////////////////////////////////// 65 // indexStorage2.constructor 66 ///////////////////////////////////////////////////////////////// 67 module("indexStorage2.constructor", { 68 teardown: function () { 69 deleteIndexedDB(this.jio); 70 } 71 }); 72 test("Constructor with empty index_keys", function () { 73 this.jio = jIO.createJIO({ 74 type: "index2", 75 database: "index2_test", 76 index_keys: [], -
test/jio.storage/indexstorage2.tests.js 0 → 100644
91 teardown: function () { 92 deleteIndexedDB(this.jio); 93 } 94 }); 95 test("can list documents", function () { 96 this.jio = jIO.createJIO({ 97 type: "index2", 98 database: "index2_test", 99 index_keys: [], 100 sub_storage: { 101 type: "dummystorage3" 102 } 103 }); 104 105 ok(this.jio.hasCapacity("list")); 106 ok(this.jio.hasCapacity("query")); -
test/jio.storage/indexstorage2.tests.js 0 → 100644
128 var context = this; 129 stop(); 130 expect(4); 131 132 DummyStorage3.prototype.put = function (id, value) { 133 equal(id, "32"); 134 deepEqual(value, {"a": 3, "b": 2, "c": 8}); 135 return id; 136 }; 137 138 DummyStorage3.prototype.get = function (id) { 139 equal(id, "32"); 140 return {"a": 3, "b": 2, "c": 8}; 141 }; 142 143 context.jio.put("32", {"a": 3, "b": 2, "c": 8}) -
test/jio.storage/indexstorage2.tests.js 0 → 100644
139 equal(id, "32"); 140 return {"a": 3, "b": 2, "c": 8}; 141 }; 142 143 context.jio.put("32", {"a": 3, "b": 2, "c": 8}) 144 .then(function () { 145 return context.jio.get("32"); 146 }) 147 .then(function (result) { 148 deepEqual(result, {"a": 3, "b": 2, "c": 8}); 149 }) 150 .fail(function (error) { 151 console.log(error); 152 }) 153 .then(function () { 154 return deleteIndexedDB(context.jio); -
test/jio.storage/indexstorage2.tests.js 0 → 100644
179 }); 180 stop(); 181 expect(3); 182 183 DummyStorage3.prototype.put = function (id, value) { 184 equal(id, "32"); 185 deepEqual(value, {a: "3", b: "2"}); 186 return id; 187 }; 188 189 context.jio.put("32", {"a": "3", "b": "2"}) 190 .then(function () { 191 return context.jio.allDocs({query: 'a: "3"'}); 192 }) 193 .then(function (result) { 194 deepEqual(result.data.rows[0], {"id": "32", "value": {}}); -
test/jio.storage/indexstorage2.tests.js 0 → 100644
297 type: "index2", 298 database: "index2_test", 299 index_keys: [], 300 sub_storage: { 301 type: "dummystorage3" 302 } 303 }); 304 stop(); 305 expect(4); 306 307 DummyStorage3.prototype.put = function (id) { 308 return id; 309 }; 310 DummyStorage3.prototype.hasCapacity = function (capacity) { 311 equal(capacity, "query"); 312 if (capacity === "query") { return true; } -
test/jio.storage/indexstorage2.tests.js 0 → 100644
397 expect(1); 398 399 DummyStorage3.prototype.put = function (id) { 400 return id; 401 }; 402 403 RSVP.all([ 404 context.jio.put("32", {"a": "3", "b": "2"}), 405 context.jio.put("21", {"a": "6", "b": "9"}), 406 context.jio.put("3", {"a": "8", "b": "5"}) 407 ]) 408 .then(function () { 409 return context.jio.allDocs(); 410 }) 411 .then(function (result) { 412 equal(result.data.total_rows, 3); -
If no query is used, buildQuery returns all of the keys from the object store which contains the indices. The object store uses the keys("32", "21", "3" here) as the primary key. Therefore the sub-storage isn't called in this case for the query.
-
src/jio.storage/indexstorage2.js 0 → 100644
41 }; 42 43 function handleUpgradeNeeded(evt, index_keys) { 44 var db = evt.target.result, store, i; 45 46 store = db.createObjectStore("index-store", { 47 keyPath: "id", 48 autoIncrement: false 49 }); 50 for (i = 0; i < index_keys.length; i += 1) { 51 store.createIndex("Index-" + index_keys[i], "doc." + index_keys[i], 52 {unique: false}); 53 } 54 } 55 56 function waitForOpenIndexedDB(db_name, index_keys, callback) { -
src/jio.storage/indexstorage2.js 0 → 100644
157 return new RSVP.Promise(function (resolve, reject) { 158 request.onerror = reject; 159 request.onsuccess = resolve; 160 }); 161 } 162 163 IndexStorage2.prototype._runQuery = function (index, value) { 164 var context = this; 165 return new RSVP.Queue() 166 .push(function () { 167 if ((context._index_keys.indexOf(index) === -1)) { 168 if (context._sub_storage.hasCapacity("query")) { 169 return context._sub_storage.buildQuery( 170 {"query": index + ":" + value} 171 ) 172 .then(function (result) { -
src/jio.storage/indexstorage2.js 0 → 100644
267 return filtered_doc; 268 }; 269 270 IndexStorage2.prototype.put = function (id, value) { 271 var context = this; 272 return context._sub_storage.put(id, value) 273 .push(function (result) { 274 return waitForOpenIndexedDB(context._database_name, 275 context._index_keys, function (db) { 276 return waitForTransaction(db, ["index-store"], "readwrite", 277 function (tx) { 278 return waitForIDBRequest(tx.objectStore("index-store").put({ 279 "id": id, 280 "doc": context._filter_doc_values(value, context._index_keys) 281 })) 282 .then(function () { -
src/jio.storage/indexstorage2.js 0 → 100644
247 function (tx) { 248 return waitForIDBRequest(tx.objectStore("index-store").getAll()) 249 .then(function (evt) { 250 return evt.target.result.map(function (value) { 251 return {"id": value.id, "value": {} }; 252 }); 253 }); 254 }); 255 }); 256 }; 257 258 IndexStorage2.prototype.get = function () { 259 return this._sub_storage.get.apply(this._sub_storage, arguments); 260 }; 261 262 IndexStorage2.prototype._filter_doc_values = function (doc, keys) { -
@preet please follow naming convention
-
-
src/jio.storage/indexstorage2.js 0 → 100644
223 } 224 query_result = temp_set; 225 temp_set = new Set(); 226 } 227 return Array.from(query_result); 228 } 229 }); 230 } 231 }); 232 }; 233 234 IndexStorage2.prototype.buildQuery = function (options) { 235 var context = this; 236 if (options.query) { 237 return this._processQueryObject(parseStringToObject(options.query)) 238 .then(function (result) { -
src/jio.storage/indexstorage2.js 0 → 100644
35 this._database_name = "jio:" + description.database; 36 this._index_keys = description.index_keys; 37 } 38 39 IndexStorage2.prototype.hasCapacity = function (name) { 40 return ((name === "list") || (name === "query")); 41 }; 42 43 function handleUpgradeNeeded(evt, index_keys) { 44 var db = evt.target.result, store, i; 45 46 store = db.createObjectStore("index-store", { 47 keyPath: "id", 48 autoIncrement: false 49 }); 50 for (i = 0; i < index_keys.length; i += 1) { -
Toggle commit list
-
added 2 commits
Toggle commit list -
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
Toggle commit list
-
added 2 commits
Toggle commit list -
added 2 commits
Toggle commit list -
added 33 commits
-
1575d745...b08e246c - 14 commits from branch
nexedi:master
- d863e2d0 - Add nocapacitystorage
- 45402dc1 - Add test for nocapacitystorage
- a7a50e23 - Add liststorage
- d05d934b - Add tests for liststorage
- 44e92bd0 - nocapacity test style fix
- c43db0e7 - add nocapacity and list storage in scenario
- ad39ea93 - use jio storage for ids
- 50234845 - IndexStorage initial commit
- cd07ec24 - fix tests, new tests and fix index2 issues
- 4f8d9ed2 - Migration handling and improved querying support
- 05bea40b - Change version change behavior
- c3ce93e6 - add include_docs and repair
- ef1472c4 - Remove unneeded parts
- 8b3842f6 - reimplement repair
- a7eed05b - Use replicatestorage to repair
- 591fc12f - Add support for manual repair
- 19a104f5 - use consistent string format
- 22094762 - fix pending issues
- 61749ec2 - use common functions for indexeddb
Toggle commit list -
1575d745...b08e246c - 14 commits from branch
-
Toggle commit list
-
Please register or sign in to post a comment