Commit 1bf77295 authored by preetwinder's avatar preetwinder

use doc prefit for index name

parent 64b99388
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
if (name === "subquery") { if (name === "subquery") {
return this._index_keys; return this._index_keys;
} }
return ((name === "list") || (name === "include")); return ((name === "list") || (name === "include")) || (name === "subquery");
}; };
function buildKeyPath(key_list) { function buildKeyPath(key_list) {
...@@ -79,7 +79,10 @@ ...@@ -79,7 +79,10 @@
store, store,
current_stores = Array.from(db.objectStoreNames), current_stores = Array.from(db.objectStoreNames),
current_indices, current_indices,
i; i,
required_indices = index_keys.map(function (value) {
return "doc." + value;
});
if (current_stores.indexOf("metadata") === -1) { if (current_stores.indexOf("metadata") === -1) {
store = db.createObjectStore("metadata", { store = db.createObjectStore("metadata", {
...@@ -95,11 +98,11 @@ ...@@ -95,11 +98,11 @@
current_indices = new Set(store.indexNames); current_indices = new Set(store.indexNames);
current_indices.delete("_id"); current_indices.delete("_id");
for (i = 0; i < index_keys.length; i += 1) { for (i = 0; i < required_indices.length; i += 1) {
if (current_indices.has(index_keys[i])) { if (current_indices.has(required_indices[i])) {
current_indices.delete(index_keys[i]); current_indices.delete(required_indices[i]);
} else { } else {
store.createIndex(index_keys[i], "doc." + index_keys[i], store.createIndex(required_indices[i], required_indices[i],
{unique: false}); {unique: false});
} }
} }
...@@ -297,7 +300,7 @@ ...@@ -297,7 +300,7 @@
key = "_id"; key = "_id";
if (options.subquery) { if (options.subquery) {
query = parseStringToObject(options.subquery); query = parseStringToObject(options.subquery);
key = query.key; key = "doc." + query.key;
value = query.value; value = query.value;
} }
if (options.include_docs === true) { if (options.include_docs === true) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment