database.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. 'use strict'
  2. /** @type {import('@adonisjs/framework/src/Env')} */
  3. const Env = use('Env')
  4. /** @type {import('@adonisjs/ignitor/src/Helpers')} */
  5. const Helpers = use('Helpers')
  6. module.exports = {
  7. /*
  8. |--------------------------------------------------------------------------
  9. | Default Connection
  10. |--------------------------------------------------------------------------
  11. |
  12. | Connection defines the default connection settings to be used while
  13. | interacting with SQL databases.
  14. |
  15. */
  16. connection: Env.get('DB_CONNECTION', 'sqlite'),
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Sqlite
  20. |--------------------------------------------------------------------------
  21. |
  22. | Sqlite is a flat file database and can be good choice under development
  23. | environment.
  24. |
  25. | npm i --save sqlite3
  26. |
  27. */
  28. sqlite: {
  29. client: 'sqlite3',
  30. connection: {
  31. filename: Helpers.databasePath(`${Env.get('DB_DATABASE', 'development')}.sqlite`)
  32. },
  33. useNullAsDefault: true
  34. },
  35. /*
  36. |--------------------------------------------------------------------------
  37. | MySQL
  38. |--------------------------------------------------------------------------
  39. |
  40. | Here we define connection settings for MySQL database.
  41. |
  42. | npm i --save mysql
  43. |
  44. */
  45. mysql: {
  46. client: 'mysql',
  47. connection: {
  48. host: Env.get('DB_HOST', 'localhost'),
  49. port: Env.get('DB_PORT', ''),
  50. user: Env.get('DB_USER', 'root'),
  51. password: Env.get('DB_PASSWORD', ''),
  52. database: Env.get('DB_DATABASE', 'adonis')
  53. }
  54. },
  55. /*
  56. |--------------------------------------------------------------------------
  57. | PostgreSQL
  58. |--------------------------------------------------------------------------
  59. |
  60. | Here we define connection settings for PostgreSQL database.
  61. |
  62. | npm i --save pg
  63. |
  64. */
  65. pg: {
  66. client: 'pg',
  67. connection: {
  68. host: Env.get('DB_HOST', 'localhost'),
  69. port: Env.get('DB_PORT', ''),
  70. user: Env.get('DB_USER', 'root'),
  71. password: Env.get('DB_PASSWORD', ''),
  72. database: Env.get('DB_DATABASE', 'adonis')
  73. }
  74. }
  75. }