nestjs-knex
nestjs-knex copied to clipboard
handle connection state
Hello, I can't find how I can handle success or error connection to the database. AfterCreate method seems not working. Any ideas on how to do it? Basically, I want to have an opportunity to point callbacks on DB connected;
KnexModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
config: {
log: new DbLogger(),
debug: true,
client: 'postgres',
useNullAsDefault: true,
connection: {
host: configService.get('DB_HOST'),
port: configService.get<number>('DB_PORT'),
username: configService.get('DB_USERNAME'),
password: configService.get('DB_PASSWORD'),
database: configService.get('DB_NAME'),
},
afterCreate: (conn, error) => {
// created with success or error
},
},
}),
}),