Search code examples
sqldatabasepostgresqlcloudtypeorm

How to connect ElephantSQL with TypeORM?


In documentation is only example showing connection with local database:

'ormconfig.json'
{
   "type": "mysql",
   "host": "localhost",
   "port": 3306,
   "username": "test",
   "password": "test",
   "database": "test"
}

I want to connect with online-based ElephantSQL and I can not find solution.


Solution

  • I was able to connect, and here is my solution.

    {
      "name": "default",
      "type": "postgres",
      "url": <URL>, 
      "synchronize": true,
      "logging": true,
      "entities": ["src/entity/*.*"]
    }
    

    URL is the url string something like "postgres://xxxxx:5432/xxxx"