1

I want to ask if it's possible to use promise based config in sequelize-cli. So, the idea behind it is that my config file is in AWS S3, but it's not formatted to match sequelize's config file (I have to reformat it in the code)

I didn't find anything in the documentation. http://docs.sequelizejs.com/manual/tutorial/migrations.html#dynamic-configuration. They say they can use a js file, but can the js file download the config file first from S3?

Thanks!

1 Answer 1

3

TL;DR you can export a promise in config.js which return the configuration object. e.g.:

module.exports = somePromise().then(data => {
  ....,
  production: {
    username: data.user,
    password: data.password,
    database: data.db,
    host: data.host,
    dialect: 'mysql',
  },
})

After an extensive research, I found out that config.js can actually handle promise.

So to make it work, you need to provide .sequelizerc file in the root folder (where you use sequelize) and copy this to the file

const path = require('path');

module.exports = {
  'config': path.resolve('config', 'config.js')
}

then, create a config.js file. These steps is documented in http://docs.sequelizejs.com/manual/tutorial/migrations.html#dynamic-configuration

The next step is to use promise in config.js. I found an answer on sequelize github issues tracker and found this issue: https://github.com/sequelize/cli/issues/668

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.