Google Cloud SQL的典型ormconfig.json文件?

问题描述 投票:3回答:1

我已经尝试了几个小时。使用TypeORM的Google Cloud SQL的ormconfig.json文件应该是什么?我设法让它在本地使用数据库的IP(使用mysql工作台和谷歌云代理并将我的IP列入白名单),但我不知道应用引擎的连接细节应该是什么。

{
  "name": "default",
  "type": "mysql",
  "host": "/cloudsql/[project:region:instance]",
  "port": "3306",
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "modules/**/*.entity.js"
  ]
}

要么

{
  "name": "default",
  "type": "mysql",
  "extra": {
    "socketPath": "/cloudsql/[project:region:instance]"
  },
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "modules/**/*.entity.js"
  ]
}

或其他什么?

非常感谢!

google-cloud-sql typeorm
1个回答
6
投票

对于那些感兴趣的人,这是解决方案:

{
  "name": "default",
  "type": "mysql",
  "extra": {
    "socketPath": "/cloudsql/[project:region:instance]"
  },
  "username": "root",
  "password": "xxxx",
  "database": "yyy",
  "synchronize": true,
  "logging": false,
  "entities": [
    "dist/**/*.entity.js"
  ]
}

请注意,我也改变了entities路径

© www.soinside.com 2019 - 2024. All rights reserved.