我正在尝试在类中使用TypeORM,但是由于某种原因,它找不到默认连接,我正在等待连接,并且我确信配置正确,因为我使用.then()测试了它,工作
class App {
public app: express.Application;
constructor() {
this.app = express();
this.connect();
this.test();
this.config();
this.routes();
}
private async connect(): Promise<Connection> {
return createConnection();
}
private async test(): Promise<User> {
const repository = getRepository(User);
const user = new User();
user.firstName = 'Daniell';
user.lastName = 'lastname';
return repository.save(user);
}
我这样称呼班级
import App from './App';
import { Server } from './Server';
(() => new Server(App))();
为什么找不到默认连接?
答案 0 :(得分:0)
通过更改类来解决它
https://stackoverflow.com/questions/ask?abc={{}}