MCPcopy
hub / github.com/mongodb/node-mongodb-native / resolveOperationArgs

Function resolveOperationArgs

test/tools/spec-runner/index.js:575–615  ·  view source on GitHub ↗
(operationName, operationArgs, context)

Source from the content-addressed store, hash-verified

573}
574
575function resolveOperationArgs(operationName, operationArgs, context) {
576 const result = [];
577 function pluck(fromObject, toArray, fields) {
578 for (const field of fields) {
579 if (fromObject[field]) toArray.push(fromObject[field]);
580 }
581 }
582
583 // TODO: migrate all operations here
584 if (operationName === 'distinct') {
585 pluck(operationArgs, result, ['fieldName', 'filter']);
586 if (result.length === 1) result.push({});
587 } else {
588 return;
589 }
590
591 // compile the options
592 const options = {};
593 if (operationArgs.options) {
594 Object.assign(options, operationArgs.options);
595 if (options.readPreference) {
596 options.readPreference = normalizeReadPreference(options.readPreference.mode);
597 }
598 }
599
600 if (operationArgs.session) {
601 if (isTransactionCommand(operationName)) return;
602 options.session = context[operationArgs.session];
603 }
604
605 result.push(options);
606
607 // determine if there is a callback to add
608 if (operationArgs.callback) {
609 result.push(() =>
610 testOperations(operationArgs.callback, context, { swallowOperationErrors: false })
611 );
612 }
613
614 return result;
615}
616
617const CURSOR_COMMANDS = new Set(['find', 'aggregate', 'listIndexes', 'listCollections']);
618const ADMIN_COMMANDS = new Set(['listDatabases']);

Callers 1

testOperationFunction · 0.85

Calls 5

pluckFunction · 0.85
normalizeReadPreferenceFunction · 0.85
testOperationsFunction · 0.85
isTransactionCommandFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected