summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-11-13 12:49:28 -0800
committerAlex Yatskov <alex@foosoft.net>2016-11-13 12:49:28 -0800
commit2587b9ae6bb9a9b5f4fc5dd17a7f043c17596a06 (patch)
tree5a18fa5e6d694a60d86de95f7b4fef2df32c766d /ext
parentdab46eda3e42e5f0a624bb285a555b078b999a99 (diff)
Dictionary simplification
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/database.js37
1 files changed, 2 insertions, 35 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 4c8703c3..6a171dd4 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -20,11 +20,10 @@
class Database {
constructor() {
this.db = null;
- this.dbVer = 6;
this.entities = {};
}
- init() {
+ prepare() {
if (this.db !== null) {
return Promise.reject('database already initialized');
}
@@ -35,41 +34,9 @@ class Database {
kanji: '++, dictionary, character',
entities: '++, dictionary',
dictionaries: '++, title, version',
- meta: 'name, value',
});
- return Promise.resolve();
- }
-
- prepare() {
- this.init();
-
- return this.db.meta.get('version').then(row => {
- return row ? row.value : 0;
- }).catch(() => {
- return 0;
- }).then(version => {
- if (this.dbVer === version) {
- return true;
- }
-
- const db = this.db;
- this.db.close();
- this.db = null;
-
- return db.delete().then(() => {
- this.init();
- return false;
- });
- });
- }
-
- seal() {
- if (this.db === null) {
- return Promise.reject('database not initialized');
- }
-
- return this.db.meta.put({name: 'version', value: this.dbVer});
+ return this.db.open();
}
findTerm(term, dictionaries) {