无法连接到数据库 - Mongoose nestJS

时间:2021-03-31 23:17:09

标签: mongodb mongoose nestjs

目前我尝试连接到数据库 mongodb。但我得到它错误:

[MongooseModule] Unable to connect to the database. Retrying (1)... +30015ms

我通过 openshift 使用连接,类似这样:

oc port-forward mongors-0 27019:27017

在nestJs的代码配置中,我遵循:

    @Module({
  imports: [MongooseModule.forRoot( serviceConfig.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: false }),
    CommonModule, AccountingModule],
  controllers: [AppController],
})
export class AppModule { }

问题是当我使用这个配置选项时:useUnifiedTopology: true,当我使用值 false 时,连接是正确的。

serviceConfig.mongoUrl 值为:

mongodb://localhost:27019/PAGOS

如果有人能帮助我,我很感激。

谢谢 问候

0 个答案:

没有答案