当前位置:网站首页>Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem

Remember that a version of @nestjs/typeorm^8.1.4 cannot be obtained Env option problem

2022-07-06 01:12:00 crayon-shin-chan

1. brief introduction

stay typeorm in , It could have been through .env File to configure connection options

But after upgrading to  @nestjs/typeorm^8.1.4 typeorm^0.3.7 after , This function is removed

2. solve

have access to  ConnectionOptionsReader To solve

import { ConnectionOptionsReader } from 'typeorm/connection/ConnectionOptionsReader'

TypeOrmModule.forRootAsync({
      useFactory: async () => {
        const reader = new ConnectionOptionsReader();
        const options = await reader.all()
        return options[0]
      }
})

ConnectionOptionsReader Various configuration files will be loaded internally

原网站

版权声明
本文为[crayon-shin-chan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060108241348.html