How can I switch between a live and a production database without duplicating code? How can I switch between a live and a production database without duplicating code? mongoose mongoose

How can I switch between a live and a production database without duplicating code?


Rather than trying to maintain connections two environments in the same code base have you considered setting up stage version of your application? Which database it connects to could be set through an environment variable or some other configuration option.

The developers would still then only have to make a change to query one or the other and you could migrate data from the stage database to production/live database once you have finished your vetting process.