繁体   English   中英

未找到连接“默认”

[英]Connection “default” was not found

错误

ConnectionNotFoundError: Connection "default" was not found.

当我开始使用依赖倒置原则时,我收到了这个错误。

ormconfig.json

{
  "name": "default",
  "type": "postgres",
  "host": "localhost",
  "port": 5432,
  "username": "postgres",
  "password": "docker",
  "database": "customer",
  "entities": [
    "./src/modules/**/infra/typeorm/entities/*.ts"
  ],
  "migrations": [
    "./src/shared/infra/typeorm/migrations/*.ts"
  ],
  "seeds": [
    "./src/shared/infra/typeorm/seeds/*.ts"
  ],
  "cli": {
    "migrationsDir": "./src/shared/infra/typeorm/migrations"
  }
}

现在列出这个

Column type for Admin#email is not defined and cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true option in tsconfig.json. Also make sure you have imported "reflect-metadata" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.

您必须使用createConnection function 创建与数据库的连接。

const connection = await createConnection();

createConnection function 返回一个connection 将此connection用于所有数据库操作。

暂无
暂无

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

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