簡體   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