Skip to content

Commit

Permalink
expose db events
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed May 22, 2017
1 parent f1d9b46 commit 51eef56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
5.0.2 / 2017-05-22
==================
- Emit event from the manager from the underlying db emits an event (fix #189)

5.0.1 / 2017-05-21
==================
- Fix typo on requesting middlewares

5.0.0 / 2017-05-21
==================
- Remove deprecated methods
Expand Down
10 changes: 9 additions & 1 deletion lib/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ Manager.prototype.open = function (uri, opts, fn) {
} else {
this._state = STATE.OPEN
this._db = db

// set up events
var self = this
;['authenticated', 'close', 'error', 'fullsetup', 'parseError', 'reconnect', 'timeout'].forEach(function (eventName) {
self._db.on(eventName, function (e) {
self.emit(eventName, e)
})
})

this.emit('open', db)
}
if (fn) {
Expand Down Expand Up @@ -212,7 +221,6 @@ Manager.prototype.close = function (force, fn) {
function close (resolve, db) {
db.close(force, function () {
self._state = STATE.CLOSED
self.emit('close')
if (fn) {
fn()
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "monk",
"description": "The wise MongoDB API",
"version": "5.0.1",
"version": "5.0.2",
"main": "lib/monk.js",
"keywords": [
"monk",
Expand Down

0 comments on commit 51eef56

Please sign in to comment.