aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/database.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-01 04:17:02 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-01 04:17:02 +0300
commit803ccc1661384ee484298f3495585d3923495dd4 (patch)
tree77b4311d85ff57d5f8c2fcadecb9a2e883d90025 /ext/bg/js/database.js
parentb24c70523479c16eca848f5aafaa887549689ac6 (diff)
merged: first draft, only supports JMdict
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r--ext/bg/js/database.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 29ab6d4e..9787b0f8 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -30,7 +30,7 @@ class Database {
this.db = new Dexie('dict');
this.db.version(2).stores({
- terms: '++id,dictionary,expression,reading',
+ terms: '++id,dictionary,expression,reading,sequence',
kanji: '++,dictionary,character',
tagMeta: '++,dictionary',
dictionaries: '++,title,version'
@@ -73,7 +73,8 @@ class Database {
glossary: row.glossary,
score: row.score,
dictionary: row.dictionary,
- id: row.id
+ id: row.id,
+ sequence: row.sequence
});
}
});
@@ -81,6 +82,28 @@ class Database {
return results;
}
+ async findEntry(sequence) {
+ if (!this.db) {
+ throw 'Database not initialized';
+ }
+
+ const entry = [];
+ await this.db.terms.where('sequence').equals(sequence).each(row => {
+ entry.push({
+ expression: row.expression,
+ reading: row.reading,
+ tags: dictFieldSplit(row.tags),
+ rules: dictFieldSplit(row.rules),
+ glossary: row.glossary,
+ score: row.score,
+ dictionary: row.dictionary,
+ id: row.id
+ });
+ });
+
+ return entry;
+ }
+
async findTermMeta(term, titles) {
if (!this.db) {
throw 'Database not initialized';