next/lib/dbconfig.ts

18 lines
799 B
TypeScript
Raw Normal View History

import { resolve } from "path";
import * as dotenv from "dotenv";
import mongoose from "mongoose";
const FUCKYOU = "/rockfic/abc-rockfic-v3";
2023-12-28 05:40:10 -05:00
dotenv.config({ path: resolve("/home/rockfic/rockfic-staging/.env") });
export const hasMigrated = true;
console.log("indbconfig");
export const uri =
process.env.NODE_ENV == "development"
2023-12-26 19:29:16 -05:00
? `mongodb://127.0.0.1/${process.env.DBNAME}?authSource=admin`
: `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@${process.env.DB}?authSource=admin`;
export const olduri =
process.env.NODE_ENV == "development"
? `mongodb://127.0.0.1/rockfic_old?authSource=admin`
2023-12-28 05:23:41 -05:00
: `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`;
!mongoose.connection.modelNames().length && !hasMigrated && mongoose.connect(uri);