aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-30 20:27:37 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-30 20:28:41 -0400
commit1a8bbf32d580173f5997754f6b36015ae212c9f9 (patch)
tree255fd53aba63556a2df30bdd6003ecab80ca5e7a /ext/bg/js
parenta6fedae9c7fd5c3d9dfe5d20a8b10ad79af7693f (diff)
Make dictionaryExists public
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/database.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 5109e9e8..effa50a6 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -322,6 +322,15 @@ class Database {
return result;
}
+ async dictionaryExists(title) {
+ this._validate();
+ const transaction = this.db.transaction(['dictionaries'], 'readonly');
+ const index = transaction.objectStore('dictionaries').index('title');
+ const query = IDBKeyRange.only(title);
+ const count = await Database._getCount(index, query);
+ return count > 0;
+ }
+
bulkAdd(objectStoreName, items, start, count) {
return new Promise((resolve, reject) => {
const transaction = this.db.transaction([objectStoreName], 'readwrite');
@@ -380,7 +389,7 @@ class Database {
}
// Verify database is not already imported
- if (await this._dictionaryExists(dictionaryTitle)) {
+ if (await this.dictionaryExists(dictionaryTitle)) {
throw new Error('Dictionary is already imported');
}
@@ -592,15 +601,6 @@ class Database {
return [termBank, termMetaBank, kanjiBank, kanjiMetaBank, tagBank];
}
- async _dictionaryExists(title) {
- const db = this.db;
- const dbCountTransaction = db.transaction(['dictionaries'], 'readonly');
- const dbIndex = dbCountTransaction.objectStore('dictionaries').index('title');
- const only = IDBKeyRange.only(title);
- const count = await Database._getCount(dbIndex, only);
- return count > 0;
- }
-
async _findGenericBulk(tableName, indexName, indexValueList, dictionaries, createResult) {
this._validate();