Comparing version 3.0.1 to 3.0.2
19
index.js
@@ -47,8 +47,7 @@ 'use strict'; | ||
this.dbIsReady = false; | ||
this.connect(); | ||
this.connecting = false; | ||
} | ||
/** | ||
* Connect to the database (will be called by the constructor) | ||
* Connect to the database | ||
* | ||
@@ -109,6 +108,5 @@ * @return {promise} - resolves if connected | ||
return setTimeout( | ||
() => tryToConnect().then(resolve), | ||
retryIntervalSeconds * 1000 | ||
); | ||
await lUtils.setTimeout(retryIntervalSeconds * 1000); | ||
return await tryToConnect(); | ||
} | ||
@@ -260,3 +258,8 @@ } | ||
return new Promise((resolve) => this.eventEmitter.once('dbIsReady', resolve)); | ||
if (!this.connecting) { | ||
this.connectiong = true; | ||
this.connect(); | ||
} | ||
return new Promise(resolve => this.eventEmitter.once('dbIsReady', resolve)); | ||
} | ||
@@ -263,0 +266,0 @@ |
{ | ||
"name": "larvitdb", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "DB wrapper module for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -52,3 +52,3 @@ [](https://travis-ci.org/larvit/larvitdb) [](https://david-dm.org/larvit/larvitdb.svg) | ||
To see when the database connection is ready to recieve commands | ||
To see when the database connection is ready to recieve commands. Will automatically connect if that is not done already. | ||
@@ -55,0 +55,0 @@ ```javascript |
25898
423