4
2
mirror of https://github.com/getbible/app.git synced 2024-12-22 15:58:55 +00:00

Merge branch 'staging' of github.com:getbible/app into staging

Please enter a commit message to explain why this merge is necessary,
This commit is contained in:
Erastus Amunwe 2020-11-05 17:31:43 +02:00
commit c19903fa23

View File

@ -134,5 +134,50 @@ export default {
}); });
}, },
async search(name, keyPath) {
let db = await this.getDb();
return new Promise((resolve, reject) => {
let trans = db.transaction([name],'readonly');
trans.oncomplete = () => {
resolve(tr);
};
let store = trans.objectStore(name);
let tr = {};
store.openCursor().onsuccess = e => {
let cursor = e.target.result;
if (cursor) {
if (keyPath == cursor.value.keyPath){
tr = cursor.value
for (const book in cursor.value.books) {
for (const chapters in book) {
for (const verses in chapters) {
for (const verse in verses) {
if(verse.text.includes(keyPath)){
console.log("We found a row with value: " + JSON.stringify(verse.text));
}
}
}
}
}
}
cursor.continue();
}
};
trans.onerror = e => {
reject(e)
}
trans.onabort = e => {
reject(e)
}
trans.commit();
});
},
} }