(commands)
| 495 | } |
| 496 | |
| 497 | function 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 | |
| 522 | function extractCrudResult(result, operation) { |
| 523 | if (Array.isArray(result) || !isRecord(result)) { |
no test coverage detected