From bcc86807e615c8bbcbcaba5c99e0552db9202e26 Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Mon, 28 Sep 2015 15:13:17 -0400 Subject: [PATCH] Update to mongoskin v2. Notes: instances of collection.findAndModify (e.g. in `queue#dequeue`) return an object with a `value` field (as well as `lastErrorObject` and `ok` fields). I've updated the code to return the doc.value where appropriate. Not sure if this is a change introduced by using mongoskin v2 or not --- lib/queue.js | 6 +++--- package.json | 47 ++++++++++++++++++++++------------------------ test/test_queue.js | 2 +- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/queue.js b/lib/queue.js index f8ed214..a8f47d7 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -32,7 +32,7 @@ Queue.prototype.get = function (id, callback) { var self = this; if (typeof id === 'string') { - id = new mongoskin.BSONPure.ObjectID(id); + id = new mongoskin.helper.toObjectID(id); } this.collection.findOne({ _id: id, queue: this.name }, function (err, data) { @@ -91,9 +91,9 @@ Queue.prototype.dequeue = function (options, callback) { this.collection.findAndModify(query, sort, update, options, function (err, doc) { if (err) return callback(err); - if (!doc) return callback(); + if (!doc || !doc.value) return callback(); - callback(null, self.job(doc)); + callback(null, self.job(doc.value)); }); }; diff --git a/package.json b/package.json index 623f1a5..42e97dd 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,24 @@ { - "name": "monq", - "version": "0.3.2", - "description": "MongoDB-backed job queue for Node.js", - "homepage": "http://github.com/scttnlsn/monq", - "author": "Scott Nelson ", - "main": "./lib/index", - - "scripts": { - "test": "./node_modules/.bin/mocha" - }, - - "repository": { - "type": "git", - "url": "git://github.com/scttnlsn/monq.git" - }, - - "dependencies": { - "mongoskin": "1.4.13" - }, - - "devDependencies": { - "async": "0.2.10", - "mocha": "1.18.2", - "sinon": "1.9.0" - } + "name": "monq", + "version": "0.3.2", + "description": "MongoDB-backed job queue for Node.js", + "homepage": "http://github.com/scttnlsn/monq", + "author": "Scott Nelson ", + "main": "./lib/index", + "scripts": { + "test": "./node_modules/.bin/mocha" + }, + "repository": { + "type": "git", + "url": "git://github.com/scttnlsn/monq.git" + }, + "dependencies": { + "mongodb": "^2.0.44", + "mongoskin": "^2.0.0" + }, + "devDependencies": { + "async": "0.2.10", + "mocha": "1.18.2", + "sinon": "1.9.0" + } } diff --git a/test/test_queue.js b/test/test_queue.js index 586ae27..b67d484 100644 --- a/test/test_queue.js +++ b/test/test_queue.js @@ -108,4 +108,4 @@ describe('Queue', function () { }); }); }); -}); \ No newline at end of file +});