Skip to content

Instantly share code, notes, and snippets.

@BretCameron
Last active June 27, 2019 14:38
Show Gist options
  • Select an option

  • Save BretCameron/dc13de4188976a3c56875139bc0539f4 to your computer and use it in GitHub Desktop.

Select an option

Save BretCameron/dc13de4188976a3c56875139bc0539f4 to your computer and use it in GitHub Desktop.
Connect to MongoDB using Mongoose
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