Cleanup
This commit is contained in:
23
node_modules/mongodb/lib/operations/find.js
generated
vendored
23
node_modules/mongodb/lib/operations/find.js
generated
vendored
@@ -3,7 +3,9 @@
|
||||
const OperationBase = require('./operation').OperationBase;
|
||||
const Aspect = require('./operation').Aspect;
|
||||
const defineAspects = require('./operation').defineAspects;
|
||||
const resolveReadPreference = require('../utils').resolveReadPreference;
|
||||
const ReadPreference = require('../core').ReadPreference;
|
||||
const maxWireVersion = require('../core/utils').maxWireVersion;
|
||||
const MongoError = require('../core/error').MongoError;
|
||||
|
||||
class FindOperation extends OperationBase {
|
||||
constructor(collection, ns, command, options) {
|
||||
@@ -11,16 +13,28 @@ class FindOperation extends OperationBase {
|
||||
|
||||
this.ns = ns;
|
||||
this.cmd = command;
|
||||
this.readPreference = resolveReadPreference(collection, this.options);
|
||||
this.readPreference = ReadPreference.resolve(collection, this.options);
|
||||
}
|
||||
|
||||
execute(server, callback) {
|
||||
// copied from `CommandOperationV2`, to be subclassed in the future
|
||||
this.server = server;
|
||||
|
||||
const cursorState = this.cursorState || {};
|
||||
// updates readPreference if setReadPreference was called on the cursor
|
||||
this.readPreference = ReadPreference.resolve(this, this.options);
|
||||
|
||||
if (typeof this.cmd.allowDiskUse !== 'undefined' && maxWireVersion(server) < 4) {
|
||||
callback(new MongoError('The `allowDiskUse` option is not supported on MongoDB < 3.2'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.explain) {
|
||||
// We need to manually ensure explain is in the options.
|
||||
this.options.explain = this.explain.verbosity;
|
||||
}
|
||||
|
||||
// TOOD: use `MongoDBNamespace` through and through
|
||||
const cursorState = this.cursorState || {};
|
||||
server.query(this.ns.toString(), this.cmd, cursorState, this.options, callback);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +42,8 @@ class FindOperation extends OperationBase {
|
||||
defineAspects(FindOperation, [
|
||||
Aspect.READ_OPERATION,
|
||||
Aspect.RETRYABLE,
|
||||
Aspect.EXECUTE_WITH_SELECTION
|
||||
Aspect.EXECUTE_WITH_SELECTION,
|
||||
Aspect.EXPLAINABLE
|
||||
]);
|
||||
|
||||
module.exports = FindOperation;
|
||||
|
||||
Reference in New Issue
Block a user