繁体   English   中英

在 TypeScript 中找不到存储库错误,当我通过 typeorm 连接到 MySQL 时遇到错误

[英]Repository Not Found Error in TypeScript, when I was connecting to MySQL through the typeorm it was encountering the error

服务器正在侦听 3000。我的 MySQL 数据库已初始化。

RepositoryNotFoundError: No repository for "User" was found. 
  Looks like this entity is not registered in current "default" connection?

message: 'No repository for "User" was found. Looks like tes.js) 
{his entity is not registered in current "default" connection?'                 
 his entity is not registered in current "default" connection?'}

我怎样才能解决这个问题?

我遇到了同样的问题,您可能在建立数据库连接之前尝试使用方法getRepository

我通过在 async 函数内部使用const connection = await createConnection()然后await connection.driver.afterConnect().then()和路由之类的东西解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM