Skip to content

Instantly share code, notes, and snippets.

@jonathanborges
Created January 4, 2019 13:06
Show Gist options
  • Save jonathanborges/db87e110ae963547b97a3a33c9b26165 to your computer and use it in GitHub Desktop.
Save jonathanborges/db87e110ae963547b97a3a33c9b26165 to your computer and use it in GitHub Desktop.
const MongoClient = require('mongodb').MongoClient
const url = `mongodb://root:mo1542653!@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin`
var _connInstance
const getInstance = async () => {
if (!_connInstance) {
_connInstance = await getConnection()
}
return _connInstance
}
const getConnection = async () => {
return await MongoClient.connect(url, { useNewUrlParser: true, poolSize: 5 })
}
exports.getInstance = getInstance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment