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

Function extractCrudResult

test/tools/spec-runner/index.js:522–538  ·  view source on GitHub ↗
(result, operation)

Source from the content-addressed store, hash-verified

520}
521
522function extractCrudResult(result, operation) {
523 if (Array.isArray(result) || !isRecord(result)) {
524 return result;
525 }
526
527 if (result.value) {
528 // some of our findAndModify results return more than just an id, so we need to pluck
529 const resultKeys = Object.keys(operation.result);
530 if (resultKeys.length === 1 && resultKeys[0] === '_id') {
531 return { _id: result.value._id };
532 }
533
534 return result.value;
535 }
536
537 return operation.result;
538}
539
540function isTransactionCommand(command) {
541 return ['startTransaction', 'commitTransaction', 'abortTransaction'].indexOf(command) !== -1;

Callers 1

testOperationFunction · 0.85

Calls 1

isRecordFunction · 0.85

Tested by

no test coverage detected