Created
January 4, 2019 13:06
-
-
Save jonathanborges/db87e110ae963547b97a3a33c9b26165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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