Skip to content

Instantly share code, notes, and snippets.

@robertoandres24
Last active October 28, 2020 20:05
Show Gist options
  • Save robertoandres24/dba7fe6df11e9ce5176837d66ba51299 to your computer and use it in GitHub Desktop.
Save robertoandres24/dba7fe6df11e9ce5176837d66ba51299 to your computer and use it in GitHub Desktop.
mongo db basic connection
const mongoose = require('mongoose')
const connect = async function () {
try {
await mongoose.connect('mongodb://localhost:27017/graphql-test', {
useNewUrlParser: true,
useUnifiedTopology: true,
})
console.log('Mongo DB is connected...')
} catch (error) {
console.log('something went wrong')
console.log(error)
}
}
module.exports = {
connect,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment