Skip to content

Instantly share code, notes, and snippets.

@stmoerman
Last active June 9, 2018 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stmoerman/0f7828400901aa239c559aa366190f1e to your computer and use it in GitHub Desktop.
Save stmoerman/0f7828400901aa239c559aa366190f1e to your computer and use it in GitHub Desktop.
const mongoose = require('mongoose');
// Init our DB
mongoose.connect('mongodb://localhost/yourdbnamehere');
const db = mongoose.connection;
// DB connection check
db.once('open', () => {
console.log('Connected!');
});
// DB error check
db.on('error', (err) => {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment