From e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d Mon Sep 17 00:00:00 2001 From: Piotr Russ Date: Mon, 16 Nov 2020 00:10:28 +0100 Subject: api, login, auth --- node_modules/mongodb/lib/operations/find.js | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 node_modules/mongodb/lib/operations/find.js (limited to 'node_modules/mongodb/lib/operations/find.js') diff --git a/node_modules/mongodb/lib/operations/find.js b/node_modules/mongodb/lib/operations/find.js new file mode 100644 index 0000000..09cb9a9 --- /dev/null +++ b/node_modules/mongodb/lib/operations/find.js @@ -0,0 +1,40 @@ +'use strict'; + +const OperationBase = require('./operation').OperationBase; +const Aspect = require('./operation').Aspect; +const defineAspects = require('./operation').defineAspects; +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) { + super(options); + + this.ns = ns; + this.cmd = command; + this.readPreference = ReadPreference.resolve(collection, this.options); + } + + execute(server, callback) { + // copied from `CommandOperationV2`, to be subclassed in the future + this.server = server; + + if (typeof this.cmd.allowDiskUse !== 'undefined' && maxWireVersion(server) < 4) { + callback(new MongoError('The `allowDiskUse` option is not supported on MongoDB < 3.2')); + return; + } + + // TOOD: use `MongoDBNamespace` through and through + const cursorState = this.cursorState || {}; + server.query(this.ns.toString(), this.cmd, cursorState, this.options, callback); + } +} + +defineAspects(FindOperation, [ + Aspect.READ_OPERATION, + Aspect.RETRYABLE, + Aspect.EXECUTE_WITH_SELECTION +]); + +module.exports = FindOperation; -- cgit v1.2.3