Created
November 3, 2023 10:36
-
-
Save popeating/8f8a1275eff496b085a707b3ca44a120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
const MongoConnect = () => { | |
if (mongoose.connections[0].readyState) { | |
console.log('already connected'); | |
return; | |
} | |
mongoose | |
.connect(process.env.MONGO_DB_URI) | |
.then(console.log('connected')) | |
.catch((e) => console.log('error', e)); | |
}; | |
export default MongoConnect; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment