diff --git a/lib/collection/query/update.js b/lib/collection/query/update.js index aef9269..3782757 100644 --- a/lib/collection/query/update.js +++ b/lib/collection/query/update.js @@ -76,8 +76,10 @@ Query.prototype.promiseUpdate = function () { options.multi = true return new Promise(function (resolve, reject) { self.collection.update(self.criteria, self.document, options, function (err, results) { - if (err) reject(err) - else resolve(results) + if (err) return reject(err) + var result = results.result || results + if (result.nModified != null) return resolve(result.nModified) + resolve(result) }) }) } diff --git a/lib/utils.js b/lib/utils.js index 4d08173..71dab82 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -131,7 +131,7 @@ exports.updateify = function (constructor, fname) { exports.mapify = function (constructor) { constructor.prototype._transforms = null constructor.prototype.map = function (fn) { - assert('function', typeof fn) + assert.equal('function', typeof fn) var transforms = this._transforms = this._transforms || [] transforms.push(fn) return this diff --git a/test/search.js b/test/search.js index ae831a3..9d65c49 100644 --- a/test/search.js +++ b/test/search.js @@ -116,7 +116,7 @@ describe('collection.find()', function () { return collection.count() .then(function (count) { assert(count) - assert('number', typeof count) + assert.equal('number', typeof count) }) }) @@ -124,7 +124,7 @@ describe('collection.find()', function () { return collection.find().count() .then(function (count) { assert(count) - assert('number', typeof count) + assert.equal('number', typeof count) }) }) @@ -132,7 +132,7 @@ describe('collection.find()', function () { collection.find().explain().count(function (err, count) { assert.ifError(err) assert(count) - assert('number', typeof count) + assert.equal('number', typeof count) done() }) }) @@ -166,7 +166,7 @@ describe('collection.find()', function () { return collection.find().skip(null).then(function (docs) { assert.equal(length, docs.length) return collection.find().skip(1).then(function (docs) { - assert(length - 1, docs.length) + assert.equal(length - 1, docs.length) }) }) }) diff --git a/test/update.js b/test/update.js index bc61120..44a60c4 100644 --- a/test/update.js +++ b/test/update.js @@ -6,7 +6,7 @@ describe('.find().update()', function () { asdf: 1 } }).then(function (count) { - assert('number', typeof count) + assert.equal('number', typeof count) return collection.find() }).then(function (docs) { assert(docs.length > 1) @@ -20,7 +20,7 @@ describe('.find().update()', function () { return collection.find().update('$set', { asdf: 2 }).then(function (count) { - assert('number', typeof count) + assert.equal('number', typeof count) return collection.find() }).then(function (docs) { assert(docs.length > 1) @@ -38,7 +38,7 @@ describe('.find().update()', function () { }).then(function (docs) { assert(docs.length > 1) assert(docs.every(function (doc) { - return doc.obj = true + return doc.obj === true })) }) })