How to connect mongodb driver to a localhost database? #mongoDb #node #mongoDbDriver
Source: https://www.udemy.com/mongodb-the-complete-developers-guide/learn/v4/t/lecture/11861304?start=0 https://docs.mongodb.com/manual/reference/connection-string/
const mongodb = require('mongodb').MongoClient;
mongodb.connect('mongodb://localhost/database_name', {useNewUrlParser: true })
.then(( client ) => {
console.log('Connected!')
client.close()
})
.catch(err => {
console.log(err)
})