diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-03 07:20:02 +0300 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-03 07:20:02 +0300 |
commit | 69ad4a7c9b1f859733909a75534e2005a9f56178 (patch) | |
tree | 93cec595a2e8183a95fc362b5551e2e68cefc9d8 /ext/bg/js/database.js | |
parent | 3b664dd908b94e1306a211e7c8b9cde74694c018 (diff) |
merged mode: implement missing stuff, refactoring
- use correct tags
- indicate popular and rare terms
- indicate definitions restricted to specific terms
- frequencies (Innocent Corpus)
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r-- | ext/bg/js/database.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 9787b0f8..0de0505d 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,sequence', + terms: '++id,dictionary,expression,reading', kanji: '++,dictionary,character', tagMeta: '++,dictionary', dictionaries: '++,title,version' @@ -40,6 +40,9 @@ class Database { kanjiMeta: '++,dictionary,character', tagMeta: '++,dictionary,name' }); + this.db.version(4).stores({ + terms: '++id,dictionary,expression,reading,sequence' + }); await this.db.open(); } @@ -74,7 +77,7 @@ class Database { score: row.score, dictionary: row.dictionary, id: row.id, - sequence: row.sequence + sequence: typeof row.sequence === 'undefined' ? -1 : row.sequence }); } }); @@ -82,14 +85,15 @@ class Database { return results; } - async findEntry(sequence) { + async findTermsBySequence(sequence, dictionary) { if (!this.db) { throw 'Database not initialized'; } - const entry = []; + const results = []; await this.db.terms.where('sequence').equals(sequence).each(row => { - entry.push({ + // if (dictionary === row.dictionary) { + results.push({ expression: row.expression, reading: row.reading, tags: dictFieldSplit(row.tags), @@ -97,11 +101,12 @@ class Database { glossary: row.glossary, score: row.score, dictionary: row.dictionary, - id: row.id + id: row.id, + sequence: typeof row.sequence === 'undefined' ? -1 : row.sequence }); }); - return entry; + return results; } async findTermMeta(term, titles) { |