我正在尝试将js代码转换为ts代码(并理解为什么已经做了一些事情)。
这是我的js代码
use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.js')[env];
const db = {};
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
这里有多个序列
db.sequelize = sequelize;
db.Sequelize = Sequelize;
有人能帮我理解它们的意义、目的以及它们存在的原因吗?
暂无答案!
目前还没有任何答案,快来回答吧!