native-mongo-util
Advanced tools
Comparing version 2.0.0 to 2.0.1
14
index.js
@@ -69,8 +69,18 @@ const Log = require('lil-logger').getLogger(__filename); | ||
promiseLibrary: Promise, | ||
loggerLevel: 'error', | ||
loggerLevel: 'info', | ||
useNewUrlParser: true | ||
} | ||
); | ||
this._db = this._client.db(); | ||
Log.debug({ msg: `DB connected: ${exports.getDBName()}` }); | ||
this._db.on('close', () => { | ||
Log.debug({ msg: `DB lost connection: ${this.getDBName()}` }); | ||
}); | ||
this._db.on('reconnect', () => { | ||
Log.debug({ msg: `DB reconnected: ${this.getDBName()}` }); | ||
}); | ||
Log.debug({ msg: `DB connected: ${this.getDBName()}` }); | ||
this.isConnecting = false; | ||
@@ -77,0 +87,0 @@ } |
{ | ||
"name": "native-mongo-util", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
23
test.js
@@ -0,1 +1,3 @@ | ||
process.env.MONGO_URL = 'mongodb://localhost/testDB'; | ||
import test from 'ava'; | ||
@@ -6,11 +8,10 @@ const { getDBName, connect, getCollection, newConnection } = require('./'); | ||
const dbName = getDBName(); | ||
t.is(dbName, 'test'); | ||
t.is(dbName, 'testDB'); | ||
}); | ||
test.serial('fetch all records from a collection', async t => { | ||
const a = await getCollection('testCol') | ||
.find() | ||
.toArray(); | ||
t.is(a.length, 0); | ||
const d = Date.now(); | ||
await getCollection('testCol').insert({ d }); | ||
const a = await getCollection('testCol').findOne({ d }); | ||
t.truthy(a, 'Doc not saved'); | ||
}); | ||
@@ -26,8 +27,6 @@ | ||
const a = await connection | ||
.getCollection('testCol') | ||
.find() | ||
.toArray(); | ||
t.is(a.length, 0); | ||
const d = Date.now(); | ||
await connection.getCollection('someCol').insert({ d }); | ||
const a = await connection.getCollection('someCol').findOne({ d }); | ||
t.truthy(a, 'Doc not saved'); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9389
180
2