mirror of
https://github.com/spacedeck/spacedeck-open.git
synced 2025-12-15 17:37:30 +01:00
add postgres support
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
"endpoint": "http://localhost:9666",
|
||||
"invite_code": "top-sekrit",
|
||||
|
||||
"storage_type": "postgres",
|
||||
"storage_config": {
|
||||
"host": "localhost",
|
||||
"database": "spacedeck",
|
||||
"username": "postgres",
|
||||
"password": "postgres"
|
||||
},
|
||||
|
||||
"storage_local_path": "./storage",
|
||||
"storage_local_db": "./database.sqlite",
|
||||
"storage_region": "eu-central-1",
|
||||
|
||||
52
models/db.js
52
models/db.js
@@ -6,24 +6,46 @@ function sequel_log(a,b,c) {
|
||||
}
|
||||
|
||||
const Sequelize = require('sequelize');
|
||||
const sequelize = new Sequelize('database', 'username', 'password', {
|
||||
host: 'localhost',
|
||||
dialect: 'sqlite',
|
||||
let sequelize;
|
||||
|
||||
pool: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
acquire: 30000,
|
||||
idle: 10000
|
||||
},
|
||||
if(config.has('storage_type') && config.get('storage_type') === 'postgres') {
|
||||
console.log('connecting to postgres');
|
||||
let postgresConfig = config.get('storage_config');
|
||||
sequelize = new Sequelize(postgresConfig.database, postgresConfig.username, postgresConfig.password, {
|
||||
host: postgresConfig.host,
|
||||
dialect: 'postgres',
|
||||
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'),
|
||||
logging: sequel_log,
|
||||
} else {
|
||||
console.log('connecting to sqlite');
|
||||
sequelize = new Sequelize('database', 'username', 'password', {
|
||||
host: 'localhost',
|
||||
dialect: 'sqlite',
|
||||
|
||||
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
|
||||
operatorsAliases: false
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
var User;
|
||||
var Session;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"node-phantom-simple": "2.2.4",
|
||||
"node-server-screenshot": "^0.2.1",
|
||||
"nodemailer": "^4.6.7",
|
||||
"pg": "^8.5.1",
|
||||
"phantomjs-prebuilt": "^2.1.16",
|
||||
"read-chunk": "^2.1.0",
|
||||
"request": "^2.88.0",
|
||||
|
||||
Reference in New Issue
Block a user