英文:
how config mongoose connect parameters in Nestjs
问题
tls: true,
tlsAllowInvalidHostnames: true,
tlsCAFile: "rds-combined-ca-bundle.pem",
英文:
in my nestjs application i want to change some connect parameters, with mongoose itself i can do it like this :
await mongoose.connect(process.env.DB, {
readPreference: "primary",
tls: true,
tlsAllowInvalidHostnames: true,
tlsCAFile: "rds-combined-ca-bundle.pem",
});
this is my nest database module how can i add those params to this?
@Module({
imports: [
MongooseModule.forRootAsync({
useFactory: async (configService: ConfigService) => ({
uri: configService.get('MONGODB_URI'),
}),
inject: [ConfigService],
}),
],
})
export class DatabaseModule {
static forFeature(models: ModelDefinition[]) {
return MongooseModule.forFeature(models);
}
}
i need set those params so i can connect to my AWS document db
答案1
得分: 1
Sure, here is the translated code snippet:
MongooseModule.forRootAsync({
imports: [ConfigModule],
connectionName: 'mySampleDB',
useFactory: async (config: ConfigService) => ({
uri: config.get<string>('MONGODB_URI'),
useNewUrlParser: true,
useUnifiedTopology: true,
}),
inject: [ConfigService],
})
英文:
Can you try something like this please:
MongooseModule.forRootAsync({
imports: [ConfigModule],
connectionName: 'mySampleDB',
useFactory: async (config: ConfigService) => ({
uri: config.get<string>('MONGODB_URI'),
useNewUrlParser: true,
useUnifiedTopology: true,
}),
inject: [ConfigService],
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论