sequelize.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. /**
  3. * [数据库配置]
  4. * @author szjcomo
  5. * @createTime 2020-08-11
  6. * @param {[type]} appInfo [description]
  7. * @return {[type]} [description]
  8. */
  9. module.exports = appInfo => {
  10. /**
  11. * [dbConfig 配置]
  12. * @type {Object}
  13. */
  14. const dbConfig = {
  15. // 单数据库操作配置
  16. dialect: 'mysql',
  17. delegate: 'model',
  18. baseDir: 'models/mysql',
  19. host: '112.74.21.142',
  20. port: 3306,
  21. database: 'ysshop',
  22. username: 'ysshop',
  23. password: 'ysshop2023',
  24. pool: {
  25. max: 30,
  26. min: 5,
  27. acquire: 60000,
  28. idle: 10000,
  29. },
  30. /**
  31. * [是否在控制台打印sql语句]
  32. * @author szjcomo
  33. * @createTime 2020-08-11
  34. * @param {...[type]} msg [description]
  35. * @return {[type]} [description]
  36. */
  37. logging: false,
  38. /**
  39. * [timezone 东八时区]
  40. * @type {String}
  41. */
  42. timezone: '+08:00',
  43. /**
  44. * [charset 设置字符集]
  45. * @type {String}
  46. */
  47. charset: 'utf8',
  48. /**
  49. * [dialectOptions 其它参数]
  50. * @type {Object}
  51. */
  52. dialectOptions: {
  53. /**
  54. * [dateStrings 让读取date类型数据时返回字符串而不是UTC时间]
  55. * @type {Boolean}
  56. */
  57. dateStrings: true,
  58. /**
  59. * [typeCast 时间格式处理]
  60. * @type {Boolean}
  61. */
  62. typeCast: true,
  63. },
  64. /**
  65. * [define 定义全局]
  66. * @type {Object}
  67. */
  68. define: {
  69. /**
  70. * [是否使用自定义表名,如何为false 那么就同模型名一致]
  71. * @type {Boolean}
  72. */
  73. freezeTableName: true,
  74. /**
  75. * [添加create,update,delete时间戳]
  76. * @type {Boolean}
  77. */
  78. timestamps: false,
  79. },
  80. };
  81. return dbConfig;
  82. };