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

Function normalizeCommandShapes

test/tools/spec-runner/index.js:497–520  ·  view source on GitHub ↗
(commands)

Source from the content-addressed store, hash-verified

495}
496
497function normalizeCommandShapes(commands) {
498 return commands.map(def => {
499 const output = JSON.parse(
500 EJSON.stringify(
501 {
502 command: def.command,
503 commandName: def.command_name || def.commandName || Object.keys(def.command)[0],
504 databaseName: def.database_name ? def.database_name : def.databaseName
505 },
506 { relaxed: true }
507 )
508 );
509 // TODO: this is a workaround to preserve sort Map type until NODE-3235 is completed
510 if (def.command.sort) {
511 output.command.sort = def.command.sort;
512 }
513 if (def.command.createIndexes) {
514 for (const [i, dbIndex] of output.command.indexes.entries()) {
515 dbIndex.key = def.command.indexes[i].key;
516 }
517 }
518 return output;
519 });
520}
521
522function extractCrudResult(result, operation) {
523 if (Array.isArray(result) || !isRecord(result)) {

Callers 1

validateExpectationsFunction · 0.85

Calls 2

mapMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected