这是我 ormconfig 配置
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
const VercelConfig: TypeOrmModuleOptions = {
type: 'postgres',
host: '
ep-aged-waterfall-13013279-pooler.us-east-1.postgres.vercel-storage.com',
port: 5432,
username: 'xxx',
password: 'xxx',
database: 'xxx',
ssl: { rejectUnauthorized: false }, // For local development, consider removing this in production
synchronize: true, // Automatically create database tables based on entities (set to false in production)
logging: process.env.NODE_ENV === 'development' ? true : ['error'],
entities: [__dirname + '/**/*.entity{.ts,.js}'],
};
const MySqlLocalConfig: TypeOrmModuleOptions = {
type: 'mysql',
host: 'xxx',
port: 3306,
username: 'root',
password: 'xxx',
database: 'xxx',
synchronize: true,
retryDelay: 500,
retryAttempts: 10,
autoLoadEntities: true,
logging: process.env.NODE_ENV === 'development' ? true : ['error'],
};
export { VercelConfig, MySqlLocalConfig };
具体我也不懂 哈哈哈
直接 app.module 就用了 TypeOrmModule.forRoot(MySqlLocalConfig)
然后 再 service 里直接整就完事了