Skip to content

Commit 51eef56

Browse files
committed
expose db events
1 parent f1d9b46 commit 51eef56

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
5.0.2 / 2017-05-22
2+
==================
3+
- Emit event from the manager from the underlying db emits an event (fix #189)
4+
5+
5.0.1 / 2017-05-21
6+
==================
7+
- Fix typo on requesting middlewares
8+
19
5.0.0 / 2017-05-21
210
==================
311
- Remove deprecated methods

lib/manager.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ Manager.prototype.open = function (uri, opts, fn) {
139139
} else {
140140
this._state = STATE.OPEN
141141
this._db = db
142+
143+
// set up events
144+
var self = this
145+
;['authenticated', 'close', 'error', 'fullsetup', 'parseError', 'reconnect', 'timeout'].forEach(function (eventName) {
146+
self._db.on(eventName, function (e) {
147+
self.emit(eventName, e)
148+
})
149+
})
150+
142151
this.emit('open', db)
143152
}
144153
if (fn) {
@@ -212,7 +221,6 @@ Manager.prototype.close = function (force, fn) {
212221
function close (resolve, db) {
213222
db.close(force, function () {
214223
self._state = STATE.CLOSED
215-
self.emit('close')
216224
if (fn) {
217225
fn()
218226
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "monk",
33
"description": "The wise MongoDB API",
4-
"version": "5.0.1",
4+
"version": "5.0.2",
55
"main": "lib/monk.js",
66
"keywords": [
77
"monk",

0 commit comments

Comments
 (0)