Open prawana-perera opened 6 years ago
I'm happy to create a PR to update the documentation if you think the above is ok.
@sushantdhiman me too... I've lost a couple of hours to find that out.
I can help with pull request if pointed to right direction.
Is an async config object still supported (as suggested in OP)? I tried this to access a secrets manager, but it seems that the index models is synchronous and file chokes on TypeError: Cannot read property 'use_env_variable' of undefined
- seems there's nothing waiting for the config to resolve or am I missing something?
So, is this available or not? Have the docs been implemented? Could not find anything
I was able to fetch configuration asynchronously by using Sequelize's beforeConnect
Connection Hook: https://sequelize.org/master/manual/hooks.html
Here's an example of how I set up my Sequelize connection:
sequelize.beforeConnect(async (config) => {
const fetchDbConfigDetails = await // implementation not shown
const pgConnStr = fetchDbConfigDetails.data.value;
const { host, port, user, password, database } = parsePgConnStr(pgConnStr);
config.database = database;
config.username = user;
config.password = password;
config.host = host;
config.port = port;
config.dialectOptions = { ssl: true };
});
For what it's worth: I have been able to use the OP's solution using the CLI.
What you are doing?
Hi, we have a requirement to asynchronously fetch the database password (e.g. from our secrets management service). The documentation on dynamic configuration (http://docs.sequelizejs.com/manual/tutorial/migrations.html#dynamic-configuration) does not seem to mention how to do this.
However having looked at the source code for how the config object is loaded (https://github.com/sequelize/cli/blob/master/src/helpers/config-helper.js#L117), this seems to be supported. I.e. it checks whether the config object is an object or promise. So we were able to do the following:
What do you expect to happen?
This info maybe helpful for others who maybe looking around. So it would be great if the documentation could be updated on how to use an async configuration object.
Thanks.