summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-06 22:19:48 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-06 22:19:48 -0800
commited2091ae1b4976b90d29f5e84efdcd41227f66b0 (patch)
tree79c96bb1a9116872b005a3bed9866ab9ab25d71e /ext/bg/js/dictionary.js
parent6eab90b89c7320476e06ab4699d6e86ef0a967ae (diff)
WIP
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index fe0284c9..f3de36f4 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -131,7 +131,7 @@ class Dictionary {
});
}
- getInfo() {
+ getDictionaries() {
if (this.db === null) {
return Promise.reject('database not initialized');
}
@@ -139,6 +139,22 @@ class Dictionary {
return this.db.dictionaries.toArray();
}
+ deleteDictionary(title) {
+ if (this.db === null) {
+ return Promise.reject('database not initialized');
+ }
+
+ const tasks = [
+ this.db.terms.where('dictionary').equals(title).delete(),
+ this.db.kanji.where('dictionary').equals(title).delete(),
+ this.db.entities.where('dictionary').equals(title).delete()
+ ];
+
+ return Promise.all(tasks).then(() => {
+ return this.db.dictionaries.where('title').equals(title).delete();
+ });
+ }
+
importDb(indexUrl, callback) {
if (this.db === null) {
return Promise.reject('database not initialized');