native-mongo-util
Advanced tools
Comparing version 1.0.4 to 1.0.5
17
index.js
const Log = require('lil-logger').getLogger(__filename); | ||
const memoize = require('memoizee'); | ||
const sleep = require('then-sleep'); | ||
const Promise = require('bluebird'); | ||
const { MongoClient } = require('mongodb'); | ||
const mongodbURL = process.env.MONGO_URL || 'mongodb://localhost/lilprod-db'; | ||
const mongodbURL = process.env.MONGO_URL || 'mongodb://localhost/test'; | ||
@@ -21,11 +21,10 @@ let _client; | ||
_client = await MongoClient.connect(mongodbURL, { | ||
promiseLibrary: require('bluebird'), | ||
loggerLevel: 'error', | ||
reconnectInterval: 2000 | ||
promiseLibrary: Promise, | ||
loggerLevel: 'error' | ||
}); | ||
_db = _client.db(); | ||
Log.debug({ msg: `DB connected: ${_db.databaseName}` }); | ||
Log.debug({ msg: `DB connected: ${exports.getDBName()}` }); | ||
isConnecting = false; | ||
} | ||
return Object.freeze(_db); | ||
return _db; | ||
}; | ||
@@ -35,5 +34,7 @@ | ||
await exports.getDB(); | ||
return Object.freeze(_client); | ||
return _client; | ||
}; | ||
exports.getDBName = () => _db.databaseName; | ||
exports.getCollection = memoize(collectionName => _db.collection(collectionName)); | ||
@@ -40,0 +41,0 @@ |
{ | ||
"name": "native-mongo-util", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
2508
37