diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-15 05:19:16 +0300 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2017-10-15 05:19:16 +0300 |
commit | 03f7ca23e118c5ca804eef35cea05070e69779c7 (patch) | |
tree | f7f66ed1a2ad3b782af8cd84ffb5d3203b1928ac /ext/bg/js/database.js | |
parent | 4203fda906a1b4a104187e54d256e5952d8ae55c (diff) |
merged mode: add secondary searches
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r-- | ext/bg/js/database.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 8350e214..dea78196 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -86,6 +86,32 @@ class Database { return results; } + async findTermsExact(term, reading, titles) { + if (!this.db) { + throw 'Database not initialized'; + } + + const results = []; + await this.db.terms.where('expression').equals(term).each(row => { + if (row.reading === reading && titles.includes(row.dictionary)) { + results.push({ + expression: row.expression, + reading: row.reading, + definitionTags: dictFieldSplit(row.definitionTags), + termTags: dictFieldSplit(row.termTags || ''), + rules: dictFieldSplit(row.rules), + glossary: row.glossary, + score: row.score, + dictionary: row.dictionary, + id: row.id, + sequence: typeof row.sequence === 'undefined' ? -1 : row.sequence + }); + } + }); + + return results; + } + async findTermsBySequence(sequence, mainDictionary) { if (!this.db) { throw 'Database not initialized'; |