Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/reconnect #295

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ Manager.prototype.open = function (uri, opts, fn) {
self.emit(eventName, e)
})
})
self.on('reconnect', function () {
self._state = STATE.OPEN
})

this.emit('open', this._db)
}
Expand Down Expand Up @@ -252,6 +255,17 @@ Manager.prototype.close = function (force, fn) {
}
}

/**
* Reconnects the connection.
*
* @return {Promise}
*/

Manager.prototype.reconnect = function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add an fn argument to be consistent with the open method?

this.open(this._connectionURI, this._connectionOptions)
this._state = STATE.OPENING
}

/**
* Lists all collections.
*
Expand Down