Skip to content

Instantly share code, notes, and snippets.

@yeungon
Created January 13, 2022 13:28
Show Gist options
  • Save yeungon/14cc81568c6a00398ee6027300a7d356 to your computer and use it in GitHub Desktop.
Save yeungon/14cc81568c6a00398ee6027300a7d356 to your computer and use it in GitHub Desktop.
appmodule - nestjs
@Module({
imports: [
StoresModule,
UserModule,
TypeOrmModule.forRoot({
type: 'mysql',
// "db" is the name of the service declared in docker-compose.yml, NOT localhost https://stackoverflow.com/questions/63492744/dockerize-nestjs-and-typeorm
host: 'db',
port: 3306,
username: 'root',
password: 'changeme',
database: 'admin',
//https://orkhan.gitbook.io/typeorm/docs/connection-options#mysql-mariadb-connection-options
//https://github.com/typeorm/typeorm/issues/390#issuecomment-292452066
charset: 'utf8mb4', //seem cannot set the charset for mysql here!!!
// For development only
autoLoadEntities: true,
synchronize: true,
}),
],
controllers: [AppController],
providers: [AppService],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment