Skip to content

Commit

Permalink
update for mongodb 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed May 16, 2018
1 parent 6f1b6d7 commit 91a4a41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ Channel.prototype.listen = function (latest) {
tailable: true,
awaitData: true,
timeout: false,
sortValue: {$natural: -1},
numberOfRetries: Number.MAX_VALUE,
sortValue: {$natural: -1},
numberOfRetries: Number.MAX_VALUE,
tailableRetryInterval: self.options.retryInterval
}
);
Expand Down Expand Up @@ -174,7 +174,7 @@ Channel.prototype.listen = function (latest) {
});

var more = function () {
cursor.nextObject(next);
cursor.next(next);
};

more();
Expand All @@ -201,7 +201,7 @@ Channel.prototype.latest = function (latest, callback) {
.find(latest ? { _id: latest._id } : null, {timeout: false})
.sort({$natural: -1})
.limit(1)
.nextObject(function (err, doc) {
.next(function (err, doc) {
if (err || doc) return callback(err, doc, collection);

collection.insert({ 'dummy': true }, { safe: true }, function (err, docs) {
Expand Down
13 changes: 7 additions & 6 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ function Connection(uri, options) {
if (uri.collection) {
this.db = uri;
} else {
MongoClient.connect(uri, options, function (err, db) {
MongoClient.connect(uri, options, function (err, client) {
if (err) return self.emit('error', err);
self.db = db;
self.emit('connect', db);
db.on('error', function (err) {
self.client = client;
self.db = client.db();
self.emit('connect', self.db);
self.db.on('error', function (err) {
self.emit('error', err);
});
});
Expand Down Expand Up @@ -54,7 +55,7 @@ Object.defineProperty(Connection.prototype, 'state', {
state = 'destroyed';
}
else if (this.db) {
state = this.db.serverConfig.isConnected()
state = this.db.serverConfig.isConnected()
? 'connected' : 'disconnected';
} else {
state = 'connecting';
Expand Down Expand Up @@ -93,7 +94,7 @@ Connection.prototype.channel = function (name, options) {
*/
Connection.prototype.close = function (callback) {
this.destroyed = true;
this.db.close(callback);
this.client.close(callback);

return this;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"url": "git://github.com/scttnlsn/mubsub.git"
},
"dependencies": {
"mongodb": "^2.0.35"
"mongodb": "^3.0.8"
},
"devDependencies": {
"mocha": "^2.2.5"
Expand Down

0 comments on commit 91a4a41

Please sign in to comment.