Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // default.json
- {
- "mongoURI":
- "mongodb+srv://mern123:<password>@mernatoz-9kdpd.mongodb.net/test?retryWrites=true&w=majority"
- }
- /* Replace <password> with your database password */
- /* ------------------------------------------------------------------ */
- // db.js
- const mongoose = require('mongoose');
- const config = require('config');
- const db = config.get('mongoURI');
- const connectDB = async () => {
- try {
- await mongoose.connect(
- db,
- {
- useNewUrlparser: true
- }
- );
- console.log('MongoDB is Connected...');
- } catch (err) {
- console.error(err.message);
- process.exit(1);
- }
- };
- module.exports = connectDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement