Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async onModuleDestroy() {
const connection = this.moduleRef.get(this.connectionName);
if (connection) {
await connection.close();
[...models.entries()].reduce((array, [key, model]) => {
if (model.db === connection) {
array.push(key);
}
return array;
}, []).forEach(deleteModel);
}
}
}