Last active
June 27, 2019 14:38
-
-
Save BretCameron/dc13de4188976a3c56875139bc0539f4 to your computer and use it in GitHub Desktop.
Connect to MongoDB using Mongoose
This file contains hidden or 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
| const express = require('express'); | |
| const mongoose = require('mongoose'); | |
| const path = require('path'); | |
| const config = require('config'); | |
| const app = express(); | |
| const db = config.get('mongoURI'); | |
| mongoose | |
| .connect(db, { useNewUrlParser: true, useCreateIndex: true, useFindAndModify: false }) | |
| .then(() => console.log('MongoDB Connected...')) | |
| .catch(err => console.log(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment