seppevs / migrate-mongo

A database migration tool for MongoDB in Node
MIT License
926 stars 163 forks source link

Import user/password/host or complete MongoDB connection URI from environment. #349

Closed voronin-de closed 3 years ago

voronin-de commented 3 years ago

Hello,

thank you for such an awesome library!

I am looking for a way to import either user, password and host or a complete connection string from an environment file. We have various environment files (in TypeScript). They contain a complete MongoDB connection string, which we use within the application.

However: I am not sure how to import it into migrate-mongo-config.js. Should I use tsc on the environment..ts files and import the resulting environment..js file and thus be able to access that connection string? Or are there other ways to do this?

voronin-de commented 3 years ago

I figured we could use process.env as well as expressions such as url: process.env.url !== undefined ? process.env.url : .... So it's probably good enough and I guess this can be closed.