Search code examples
knex.js

Set default database for Knex?


How can you set the default database in knexfile.js?

module.exports = {
  local: {
    client: 'postgresql',
    connection: {
      database: 'main'
    },
    pool: {
      min: 2,
      max: 10
    },
    default: true  // <-- incorrect, whats the right way?
  }
}

Solution

  • If you mean by default ”how to make knex conmandline client to select which configuration to use”, then the default is called ’development’ and you can choose different configuration by setting NODE_PROFILE environment variable.

    Sorry for the brief answer from mobile phone. I’m writing this out from my memory so names mentioned above could use fact check.