final fix for all api
This commit is contained in:
@@ -15,8 +15,9 @@ import mongoose from "mongoose";
|
||||
// };
|
||||
const connectToAchievementsDB = async () => {
|
||||
if (mongoose.connection.readyState >= 1) {
|
||||
console.log("✅ Already connected to Achievements MongoDB");
|
||||
return;
|
||||
console.log("⚠️ Existing connection found. Closing it...");
|
||||
await mongoose.connection.close();
|
||||
console.log("✅ Previous connection closed");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const connectToDatabase = async () => {
|
||||
if (mongoose.connection.readyState >= 1) return;
|
||||
if (mongoose.connection.readyState >= 1) {
|
||||
console.log("⚠️ Existing connection found. Closing it...");
|
||||
await mongoose.connection.close();
|
||||
console.log("✅ Previous connection closed");
|
||||
};
|
||||
|
||||
try {
|
||||
await mongoose.connect(process.env.MongoURL, {
|
||||
|
||||
@@ -2,7 +2,11 @@ import mongoose from "mongoose";
|
||||
|
||||
const connectToEventDB = async () => {
|
||||
|
||||
if (mongoose.connection.readyState >= 1) return;
|
||||
if (mongoose.connection.readyState >= 1) {
|
||||
console.log("⚠️ Existing connection found. Closing it...");
|
||||
await mongoose.connection.close();
|
||||
console.log("✅ Previous connection closed");
|
||||
};
|
||||
|
||||
try {
|
||||
await mongoose.connect(process.env.MongoURL!, {
|
||||
|
||||
@@ -2,7 +2,11 @@ import mongoose from "mongoose";
|
||||
|
||||
const connectToTeamDB = async () => {
|
||||
|
||||
if (mongoose.connection.readyState >= 1) return;
|
||||
if (mongoose.connection.readyState >= 1) {
|
||||
console.log("⚠️ Existing connection found. Closing it...");
|
||||
await mongoose.connection.close();
|
||||
console.log("✅ Previous connection closed");
|
||||
};
|
||||
|
||||
try {
|
||||
await mongoose.connect(process.env.MongoURL!, {
|
||||
|
||||
Reference in New Issue
Block a user