Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- MongooseModuleOptions,
- MongooseModuleAsyncOptions,
- } from '@nestjs/mongoose';
- import { ConfigModule, ConfigService } from '@nestjs/config';
- class MongooseConfig {
- static getMongooseConfigs(
- configService: ConfigService,
- ): MongooseModuleOptions {
- return {
- uri: configService.get<string>('mongodb.uri'),
- useNewUrlParser: true,
- useUnifiedTopology: true,
- };
- }
- }
- const MongooseAsyncOptions: MongooseModuleAsyncOptions = {
- connectionName: 'mongodb-database',
- imports: [ConfigModule],
- inject: [ConfigService],
- useFactory: async (
- configService: ConfigService,
- ): Promise<MongooseModuleOptions> =>
- MongooseConfig.getMongooseConfigs(configService),
- };
- export { MongooseAsyncOptions };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement