I have a TypeORM project I am trying to deploy to Heroku. Heroku's Postgres addon just gives me one database URL. That URL locally on my end would look like: postgres://user_name:password@localhost:5432/project_table
TypeORM spreads those things out a bit, though. In knex I can just do:
require("dotenv").config();module.exports={development:{client:"pg",// 🔻 Points to our local Postgresql databaseconnection:process.env.DATABASE_URL,}};
But I don't know how to consolidate that down just one variable in the ormconfig.ts. Any ideas? I'm really loving using TypeORM so far and would love to get it hosted! Lol
Solved: Answer in reply below
I have a TypeORM project I am trying to deploy to Heroku. Heroku's Postgres addon just gives me one database URL. That URL locally on my end would look like:
postgres://user_name:password@localhost:5432/project_table
TypeORM spreads those things out a bit, though. In knex I can just do:
But I don't know how to consolidate that down just one variable in the ormconfig.ts. Any ideas? I'm really loving using TypeORM so far and would love to get it hosted! Lol
You can extract all data you need from the connection string. This module may help a lot, but it's also manually not that hard.
npmjs.com/package/pg-connection-st...
But, yeah would be really cool if typeorm supports this by default somehow.
They do! :) Posted the answer above! 🔥
This is how I have my TypeORM set up that works exactly the way I wanted it: