mirror of
https://github.com/spacedeck/spacedeck-open.git
synced 2025-12-15 17:37:30 +01:00
unify config, add postgres decimal fix
This commit is contained in:
@@ -7,11 +7,12 @@
|
|||||||
"endpoint": "http://localhost:9666",
|
"endpoint": "http://localhost:9666",
|
||||||
"invite_code": "top-sekrit",
|
"invite_code": "top-sekrit",
|
||||||
|
|
||||||
"storage_type": "postgres",
|
"storage_dialect": "sqlite",
|
||||||
"storage_postgres_host": "localhost",
|
|
||||||
"storage_postgres_database": "spacedeck",
|
"storage_host": "localhost",
|
||||||
"storage_postgres_username": "postgres",
|
"storage_database": "spacedeck",
|
||||||
"storage_postgres_password": "postgres",
|
"storage_username": "username",
|
||||||
|
"storage_password": "password",
|
||||||
|
|
||||||
"storage_local_path": "./storage",
|
"storage_local_path": "./storage",
|
||||||
"storage_local_db": "./database.sqlite",
|
"storage_local_db": "./database.sqlite",
|
||||||
|
|||||||
50
models/db.js
50
models/db.js
@@ -6,50 +6,28 @@ function sequel_log(a,b,c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
let sequelize;
|
const sequelize = new Sequelize(
|
||||||
|
config.get('storage_database'),
|
||||||
if(config.has('storage_type') && config.get('storage_type') === 'postgres') {
|
config.get('storage_username'),
|
||||||
console.log('connecting to postgres');
|
config.get('storage_password'),
|
||||||
sequelize = new Sequelize(
|
{
|
||||||
config.get('storage_postgres_database'),
|
host: config.get('storage_host'),
|
||||||
config.get('storage_postgres_username'),
|
dialect: config.get('storage_dialect'),
|
||||||
config.get('storage_postgres_password'),
|
|
||||||
{
|
|
||||||
host: config.get('storage_postgres_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
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log('connecting to sqlite');
|
|
||||||
sequelize = new Sequelize('database', 'username', 'password', {
|
|
||||||
host: 'localhost',
|
|
||||||
dialect: 'sqlite',
|
|
||||||
|
|
||||||
pool: {
|
pool: {
|
||||||
max: 5,
|
max: 5,
|
||||||
min: 0,
|
min: 0,
|
||||||
acquire: 30000,
|
acquire: 30000,
|
||||||
idle: 10000
|
idle: 10000
|
||||||
},
|
},
|
||||||
|
|
||||||
// SQLite only
|
|
||||||
storage: config.get('storage_local_db'),
|
|
||||||
logging: sequel_log,
|
logging: sequel_log,
|
||||||
|
|
||||||
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
|
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
|
||||||
operatorsAliases: false
|
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 User;
|
||||||
var Session;
|
var Session;
|
||||||
|
|||||||
Reference in New Issue
Block a user