Knex Env Config
Create Knex config objects with defaults loaded from the environment.
Usage
Install
npm install knex-env-config
Example
Create a Knex config object by calling knexEnvConfig
and pass it to the Knex
constructor:
;; const knexConfig = ;const knex = ;
Or override some options:
const knexConfig = ; const knex = ;
Or pass a custom env
object:
const env = DATABASE_USER: 'root';const knexConfig = knexEnvConfig; const knex = ;
Supported options
See the Knex docs for more info.
env key | knex option |
---|---|
DATABASE_CLIENT |
client |
DATABASE_VERSION |
version |
DATABASE_DEBUG |
debug |
DATABASE_URL |
connection |
DATABASE_USER |
connection.user |
DATABASE_PASSWORD |
connection.password |
DATABASE_HOST |
connection.host |
DATABASE_NAME |
connection.database |
DATABASE_FILENAME |
connection.filename |
DATABASE_SOCKET_PATH |
connection.socketPath |
DATABASE_POOL_MIN |
pool.min |
DATABASE_POOL_MAX |
pool.max |
DATABASE_SEEDS_DIRECTORY |
seeds.directory |
DATABASE_MIGRATIONS_DIRECTORY |
migrations.directory |
DATABASE_MIGRATIONS_TABLE |
migrations.tableName |