diff --git a/README.md b/README.md index a70e100..0816c80 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,26 @@ For advanced media conversion: By default, media files are uploaded to the ```storage``` folder. The database is stored in ```database.sqlite``` by default. +# Other databases (Not officially supported) + +## Postgres + +Add the [pg](https://www.npmjs.com/package/pg) module and change the config/default.json to + +``` +"storage_dialect": "postgres", +``` + +Adapt the other values as needed + +``` +"storage_host": "localhost", +"storage_database": "spacedeck", +"storage_username": "username", +"storage_password": "password", +``` + + # Run with Docker - configure `config/default.json` diff --git a/config/default.json b/config/default.json index 2838396..fcc459e 100644 --- a/config/default.json +++ b/config/default.json @@ -7,6 +7,13 @@ "endpoint": "http://localhost:9666", "invite_code": "top-sekrit", + "storage_dialect": "sqlite", + + "storage_host": "localhost", + "storage_database": "spacedeck", + "storage_username": "username", + "storage_password": "password", + "storage_local_path": "./storage", "storage_local_db": "./database.sqlite", "storage_region": "eu-central-1", diff --git a/models/db.js b/models/db.js index 8cb3d17..03de63d 100644 --- a/models/db.js +++ b/models/db.js @@ -6,24 +6,28 @@ function sequel_log(a,b,c) { } const Sequelize = require('sequelize'); -const sequelize = new Sequelize('database', 'username', 'password', { - host: 'localhost', - dialect: 'sqlite', - - pool: { - max: 5, - min: 0, - acquire: 30000, - idle: 10000 - }, - - // SQLite only - storage: config.get('storage_local_db'), - logging: sequel_log, - - // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators - operatorsAliases: false -}); +const sequelize = new Sequelize( + config.get('storage_database'), + config.get('storage_username'), + config.get('storage_password'), + { + host: config.get('storage_host'), + dialect: config.get('storage_dialect'), + pool: { + max: 5, + min: 0, + acquire: 30000, + idle: 10000 + }, + logging: sequel_log, + // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators + operatorsAliases: false, + // SQLite only + storage: config.get('storage_local_db') + } +); +// https://github.com/sequelize/sequelize/issues/8019#issuecomment-384316346 +Sequelize.postgres.DECIMAL.parse = function (value) { return parseFloat(value); }; var User; var Session;