Closed tjhiggins closed 2 years ago
Thanks for this PR.
You can also use something like that to prevent adding the data source several times:
import { addTransactionalDataSource, getDataSourceByName } from 'typeorm-transactional';
// ...
TypeOrmModule.forRootAsync({
dataSourceFactory: async (options) => {
return getDataSourceByName('default') || addTransactionalDataSource(new DataSource(options));
},
});
Thanks for this PR.
You can also use something like that to prevent adding the data source several times:
import { addTransactionalDataSource, getDataSourceByName } from 'typeorm-transactional'; // ... TypeOrmModule.forRootAsync({ dataSourceFactory: async (options) => { return getDataSourceByName('default') || addTransactionalDataSource(new DataSource(options)); }, });
I tried that first, but the nestjs typeorm didn't like reusing the same datasource. I think there was a race condition during hot reloading where it would get closed by the previous server.
Thanks for merging!
Needed to be able to delete the datasource for hot reloading via webpack to work with nestjs. Thanks for the fork!
example: