diff options
author | Musee Ullah <lae@lae.is> | 2017-07-27 00:18:57 -0700 |
---|---|---|
committer | Musee Ullah <lae@lae.is> | 2017-07-27 00:18:57 -0700 |
commit | 1d5bdddfa62438e79384885eaa324c8ec4161229 (patch) | |
tree | e5cace6db33efe88b3547b5aa426e8f90a65f196 /ext/bg | |
parent | 390cb12896607144fcd1046950f3a2aa680db71b (diff) |
Import terms with transactional adds instead of bulkAdd
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/database.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 70aeb0d7..4829356c 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -189,20 +189,19 @@ class Database { }; const termsLoaded = (title, entries, total, current) => { - const rows = []; - for (const [expression, reading, tags, rules, score, ...glossary] of entries) { - rows.push({ - expression, - reading, - tags, - rules, - score, - glossary, - dictionary: title - }); - } - - return this.db.terms.bulkAdd(rows).then(() => { + return this.db.transaction('rw', this.db.terms, function() { + for (const [expression, reading, tags, rules, score, ...glossary] of entries) { + this.db.terms.add({ + expression, + reading, + tags, + rules, + score, + glossary, + dictionary: title + }); + } + }).then(() => { if (callback) { callback(total, current); } |