【发布时间】:2021-09-08 11:16:26
【问题描述】:
有很多关于在 NestJs 中连接数据库的问题。
但我必须只使用 URL(包括主机、端口、数据库)、用户名、密码来连接数据库。
它没有用,尽管有人告诉我有必要使用user 而不是username 或使用像ex) mysql://localhost:3306/demo?user=test 这样的URL 添加用户名。
我该如何解决这个问题?谢谢
createMainDBTypeOrmOptions(): TypeOrmModuleOptions {
return {
type: this.configDBProperties.mainType,
replication: {
master: {
url: 'mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF8',
username: this.configDBProperties.mainMasterUsername,
password: this.configDBProperties.mainMasterPassword,
},
slaves: [
{
url: 'mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF8',
username: this.configDBProperties.mainSlaveUsername,
password: this.configDBProperties.mainSlavePassword,
},
],
},
entities: [School, Student],
};
}
【问题讨论】:
标签: typescript nestjs typeorm