first commit
This commit is contained in:
commit
aa7869eb33
386 files changed
+69375
No files matched your search
Executable
+66
@@ -0,0 +1,66 @@
|
||||
var config = require('../../core/util.js').getConfig();
|
||||
|
||||
var watch = config.watch;
|
||||
if(watch) {
|
||||
var settings = {
|
||||
exchange: watch.exchange,
|
||||
pair: [watch.currency, watch.asset]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we use single database where
|
||||
* all our tables are stored. The default is to store
|
||||
* every exchange into it's own db.
|
||||
*
|
||||
* Set config.postgresql.database to use single db setup
|
||||
*/
|
||||
function useSingleDatabase() {
|
||||
return !!config.postgresql.database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Postgres has tables in lowercase if you don't
|
||||
* escape their names. Which we don't and so let's
|
||||
* just lowercase them.
|
||||
*/
|
||||
function useLowerCaseTableNames() {
|
||||
return !config.postgresql.noLowerCaseTableName;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
settings: settings,
|
||||
|
||||
// true if we have single db setup (see postrgesql.database config key)
|
||||
useSingleDatabase: useSingleDatabase,
|
||||
|
||||
// returns DB name (depends on single db setup)
|
||||
database: function () {
|
||||
return useSingleDatabase() ?
|
||||
config.postgresql.database :
|
||||
config.watch.exchange.toLowerCase().replace(/\-/g,'');
|
||||
},
|
||||
|
||||
// returns table name which can be different if we use
|
||||
// single or multiple db setup.
|
||||
table: function (name) {
|
||||
if (useSingleDatabase()) {
|
||||
name = watch.exchange.replace(/\-/g,'') + '_' + name;
|
||||
}
|
||||
var fullName = [name, settings.pair.join('_')].join('_');
|
||||
return useLowerCaseTableNames() ? fullName.toLowerCase() : fullName;
|
||||
},
|
||||
|
||||
startconstraint: function (name) {
|
||||
if (useSingleDatabase()) {
|
||||
name = watch.exchange.replace(/\-/g,'') + '_' + name;
|
||||
}
|
||||
var fullName = [name, settings.pair.join('_')].join('_');
|
||||
return useLowerCaseTableNames() ? fullName.toLowerCase() + '_start_key' : fullName + '_start_key';
|
||||
},
|
||||
|
||||
// postgres schema name. defaults to 'public'
|
||||
schema: function () {
|
||||
return config.postgresql.schema ? config.postgresql.schema : 'public';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user