First off it's my first time with Sequelize so be patient.
I'd like to use https://github.com/sequelize/cli along with https://github.com/lorenwest/node-config
I want sequelize to be able to "compose" it's configuration from multiple source files, the same manner that node-config does.
By now I've worked it out with
.sequelizerc
var path = require('path')
var Config = require('config');
var env =Config.util.getEnv('NODE_ENV');
module.exports = {
'config': path.resolve('config', env + '.json')
}
development.json ie
{
"app": {
"name": "my api"
},
"server": {
"port": 8081
},
"development": {
"username": "username",
"password": "password",
"database": "database",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
You can see i have to set a redundant env key with no logical meaning in all my env.json files.
is there a better way ?
drawback
To get the data:
var env =Config.util.getEnv('NODE_ENV');
var configDb = Config.get(env);
and this way all the options of File Load Order are lost.
https://github.com/lorenwest/node-config/wiki/Configuration-Files
Other way
sequelize db:migrate --url 'mysql://root:password@mysql_host.com/database_name'
with the standard node-config json files.