From b018adf240679ec59a7344e30be39400f1ecd8af Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 22 Aug 2019 11:12:36 +0200 Subject: Initial commit --- config/database.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 config/database.js (limited to 'config/database.js') diff --git a/config/database.js b/config/database.js new file mode 100644 index 0000000..a7a2776 --- /dev/null +++ b/config/database.js @@ -0,0 +1,84 @@ +'use strict' + +/** @type {import('@adonisjs/framework/src/Env')} */ +const Env = use('Env') + +/** @type {import('@adonisjs/ignitor/src/Helpers')} */ +const Helpers = use('Helpers') + +module.exports = { + /* + |-------------------------------------------------------------------------- + | Default Connection + |-------------------------------------------------------------------------- + | + | Connection defines the default connection settings to be used while + | interacting with SQL databases. + | + */ + connection: Env.get('DB_CONNECTION', 'sqlite'), + + /* + |-------------------------------------------------------------------------- + | Sqlite + |-------------------------------------------------------------------------- + | + | Sqlite is a flat file database and can be a good choice for a development + | environment. + | + | npm i --save sqlite3 + | + */ + sqlite: { + client: 'sqlite3', + connection: { + filename: Helpers.databasePath(`${Env.get('DB_DATABASE', 'development')}.sqlite`) + }, + useNullAsDefault: true, + debug: Env.get('DB_DEBUG', false) + }, + + /* + |-------------------------------------------------------------------------- + | MySQL + |-------------------------------------------------------------------------- + | + | Here we define connection settings for MySQL database. + | + | npm i --save mysql + | + */ + mysql: { + client: 'mysql', + connection: { + host: Env.get('DB_HOST', 'localhost'), + port: Env.get('DB_PORT', ''), + user: Env.get('DB_USER', 'root'), + password: Env.get('DB_PASSWORD', ''), + database: Env.get('DB_DATABASE', 'adonis') + }, + debug: Env.get('DB_DEBUG', false) + }, + + /* + |-------------------------------------------------------------------------- + | PostgreSQL + |-------------------------------------------------------------------------- + | + | Here we define connection settings for PostgreSQL database. + | + | npm i --save pg + | + */ + pg: { + client: 'pg', + connection: { + host: Env.get('DB_HOST', 'localhost'), + port: Env.get('DB_PORT', ''), + user: Env.get('DB_USER', 'root'), + password: Env.get('DB_PASSWORD', ''), + database: Env.get('DB_DATABASE', 'adonis') + }, + debug: Env.get('DB_DEBUG', false) + } +} -- cgit v1.2.3-54-g00ecf