refactor(dbconfig): make db url ternary check if env == production

This commit is contained in:
parent 7f12cb0af9
commit ec050390ad
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -6,12 +6,12 @@ dotenv.config({ path: resolve("/home/rockfic/rockfic-staging/.env") });
export const hasMigrated = false; export const hasMigrated = false;
console.log("indbconfig"); console.log("indbconfig");
export const uri = export const uri =
process.env.NODE_ENV == "development" process.env.NODE_ENV === "production"
? `mongodb://127.0.0.1/${process.env.DBNAME}?authSource=admin` ? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin`
: `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin`; : `mongodb://127.0.0.1/${process.env.DBNAME}?authSource=admin`;
export const olduri = export const olduri =
process.env.NODE_ENV == "development" process.env.NODE_ENV === "production"
? `mongodb://127.0.0.1/rockfic_old?authSource=admin` ? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`
: `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`; : `mongodb://127.0.0.1/rockfic_old?authSource=admin`;
!mongoose.connection.modelNames().length && !hasMigrated && mongoose.connect(uri); !mongoose.connection.modelNames().length && !hasMigrated && mongoose.connect(uri);