diff --git a/package.json b/package.json index c1a2caa..b8aa674 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "homepage": "https://github.com/Snooful/SQLite-Storage#readme", "dependencies": { - "@snooful/settings-base": "^1.0.1" + "@snooful/settings-base": "^1.0.1", + "sqlite": "^3.0.0" } -} \ No newline at end of file +} diff --git a/settings.js b/settings.js index 6968ca7..f5f2705 100644 --- a/settings.js +++ b/settings.js @@ -1,15 +1,15 @@ const base = require("@snooful/settings-base"); +const sqlite = require("sqlite"); /** * Manages settings. */ class SQLiteSettingsManager extends base.BaseSettingsManager { /** - * @param {SQLiteDatabase} database The database to store settings in. + * @param {string} databasePath The path to the database to store settings in. */ - constructor(database) { - this.database = database; - this.init(); + constructor(databasePath) { + super(); /** * The settings cache. @@ -17,6 +17,15 @@ class SQLiteSettingsManager extends base.BaseSettingsManager { this.settings = {}; this.setStatement = null; + + // Open the database and init + sqlite.open(databasePath).then(database => { + base.debug("opened settings database"); + + this.database = database; + this.init(); + }); + } /**