next/lib/dbconfig.ts

15 lines
734 B
TypeScript

import mongoose from "mongoose";
const FUCKYOU = "/rockfic/abc-rockfic-v3";
// dotenv.config({ path: resolve("/home/rockfic/rockfic-staging/.env") });
export const hasMigrated = true;
export const uri =
process.env.NODE_ENV === "production" && !process.env.TEST
? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin`
: `mongodb://127.0.0.1/${process.env.DBNAME}`;
export const olduri =
process.env.NODE_ENV === "production" && !process.env.TEST
? `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);