diff options
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r-- | ext/bg/js/database.js | 27 |
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'; |