Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/mongodb/lib/operations/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
const buildCountCommand = require('./common_functions').buildCountCommand;
const OperationBase = require('./operation').OperationBase;
class CountOperation extends OperationBase {
constructor(cursor, applySkipLimit, options) {
super(options);
this.cursor = cursor;
this.applySkipLimit = applySkipLimit;
}
execute(callback) {
const cursor = this.cursor;
const applySkipLimit = this.applySkipLimit;
const options = this.options;
if (applySkipLimit) {
if (typeof cursor.cursorSkip() === 'number') options.skip = cursor.cursorSkip();
if (typeof cursor.cursorLimit() === 'number') options.limit = cursor.cursorLimit();
}
// Ensure we have the right read preference inheritance
if (options.readPreference) {
cursor.setReadPreference(options.readPreference);
}
if (
typeof options.maxTimeMS !== 'number' &&
cursor.cmd &&
typeof cursor.cmd.maxTimeMS === 'number'
) {
options.maxTimeMS = cursor.cmd.maxTimeMS;
}
let finalOptions = {};
finalOptions.skip = options.skip;
finalOptions.limit = options.limit;
finalOptions.hint = options.hint;
finalOptions.maxTimeMS = options.maxTimeMS;
// Command
finalOptions.collectionName = cursor.namespace.collection;
let command;
try {
command = buildCountCommand(cursor, cursor.cmd.query, finalOptions);
} catch (err) {
return callback(err);
}
// Set cursor server to the same as the topology
cursor.server = cursor.topology.s.coreTopology;
// Execute the command
cursor.topology.command(
cursor.namespace.withCollection('$cmd'),
command,
cursor.options,
(err, result) => {
callback(err, result ? result.result.n : null);
}
);
}
}
module.exports = CountOperation;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0531 ]-- |