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