Changes
This commit is contained in:
17
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
17
node_modules/mongodb/lib/operations/find_and_modify.js
generated
vendored
@@ -8,6 +8,8 @@ const executeCommand = require('./db_ops').executeCommand;
|
||||
const formattedOrderClause = require('../utils').formattedOrderClause;
|
||||
const handleCallback = require('../utils').handleCallback;
|
||||
const ReadPreference = require('../core').ReadPreference;
|
||||
const maxWireVersion = require('../core/utils').maxWireVersion;
|
||||
const MongoError = require('../error').MongoError;
|
||||
|
||||
class FindAndModifyOperation extends OperationBase {
|
||||
constructor(collection, query, sort, doc, options) {
|
||||
@@ -86,6 +88,21 @@ class FindAndModifyOperation extends OperationBase {
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
if (options.hint) {
|
||||
// TODO: once this method becomes a CommandOperationV2 we will have the server
|
||||
// in place to check.
|
||||
const unacknowledgedWrite = options.writeConcern && options.writeConcern.w === 0;
|
||||
if (unacknowledgedWrite || maxWireVersion(coll.s.topology) < 8) {
|
||||
callback(
|
||||
new MongoError('The current topology does not support a hint on findAndModify commands')
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
queryObject.hint = options.hint;
|
||||
}
|
||||
|
||||
// Execute the command
|
||||
executeCommand(coll.s.db, queryObject, options, (err, result) => {
|
||||
if (err) return handleCallback(callback, err, null);
|
||||
|
||||
Reference in New Issue
Block a user