Skip to content

Commit 342a637

Browse files
committed
Merge branch '2.2' of github.com:mongodb/node-mongodb-native into 2.2
2 parents 9d4463f + c9a49f8 commit 342a637

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

lib/collection.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ define.classMethod('updateOne', {callback: true, promise:true});
916916
* @param {Collection~updateWriteOpCallback} [callback] The command result callback
917917
* @return {Promise} returns Promise if no callback passed
918918
*/
919-
Collection.prototype.replaceOne = function(filter, update, options, callback) {
919+
Collection.prototype.replaceOne = function(filter, doc, options, callback) {
920920
var self = this;
921921
if(typeof options == 'function') callback = options, options = {};
922922
options = shallowClone(options)
@@ -928,30 +928,30 @@ Collection.prototype.replaceOne = function(filter, update, options, callback) {
928928
}
929929

930930
// Execute using callback
931-
if(typeof callback == 'function') return replaceOne(self, filter, update, options, callback);
931+
if(typeof callback == 'function') return replaceOne(self, filter, doc, options, callback);
932932

933933
// Return a Promise
934934
return new this.s.promiseLibrary(function(resolve, reject) {
935-
replaceOne(self, filter, update, options, function(err, r) {
935+
replaceOne(self, filter, doc, options, function(err, r) {
936936
if(err) return reject(err);
937937
resolve(r);
938938
});
939939
});
940940
}
941941

942-
var replaceOne = function(self, filter, update, options, callback) {
942+
var replaceOne = function(self, filter, doc, options, callback) {
943943
// Set single document update
944944
options.multi = false;
945945
// Execute update
946-
updateDocuments(self, filter, update, options, function(err, r) {
946+
updateDocuments(self, filter, doc, options, function(err, r) {
947947
if(callback == null) return;
948948
if(err && callback) return callback(err);
949949
if(r == null) return callback(null, {result: {ok:1}});
950950
r.matchedCount = r.result.n;
951951
r.modifiedCount = r.result.nModified != null ? r.result.nModified : r.result.n;
952952
r.upsertedId = Array.isArray(r.result.upserted) && r.result.upserted.length > 0 ? r.result.upserted[0] : null;
953953
r.upsertedCount = Array.isArray(r.result.upserted) && r.result.upserted.length ? r.result.upserted.length : 0;
954-
r.ops = [update];
954+
r.ops = [doc];
955955
if(callback) callback(null, r);
956956
});
957957
}

lib/cursor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ define.classMethod('close', {callback: true, promise:true});
979979
* Map all documents using the provided function
980980
* @method
981981
* @param {function} [transform] The mapping transformation method.
982-
* @return {null}
982+
* @return {Cursor}
983983
*/
984984
Cursor.prototype.map = function(transform) {
985985
this.cursorState.transforms = { doc: transform };

lib/db.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,9 +1450,10 @@ var authenticate = function(self, username, password, options, callback) {
14501450

14511451
// the default db to authenticate against is 'self'
14521452
// if authententicate is called from a retry context, it may be another one, like admin
1453-
var authdb = options.authdb ? options.authdb : options.dbName;
1453+
var authdb = options.dbName ? options.dbName : self.databaseName;
1454+
authdb = self.authSource ? self.authSource : authdb;
1455+
authdb = options.authdb ? options.authdb : authdb;
14541456
authdb = options.authSource ? options.authSource : authdb;
1455-
authdb = authdb ? authdb : self.databaseName;
14561457

14571458
// Callback
14581459
var _callback = function(err, result) {

0 commit comments

Comments
 (0)