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

Method command

src/cmap/connection.ts:625–660  ·  view source on GitHub ↗
(
    ns: MongoDBNamespace,
    command: Document,
    options: CommandOptions & Abortable = {},
    responseType?: MongoDBResponseConstructor
  )

Source from the content-addressed store, hash-verified

623 ): Promise<Document>;
624
625 public async command(
626 ns: MongoDBNamespace,
627 command: Document,
628 options: CommandOptions & Abortable = {},
629 responseType?: MongoDBResponseConstructor
630 ): Promise<Document> {
631 this.throwIfAborted();
632 options.signal?.throwIfAborted();
633
634 for await (const document of this.sendCommand(ns, command, options, responseType)) {
635 if (options.timeoutContext?.csotEnabled()) {
636 if (MongoDBResponse.is(document)) {
637 if (document.isMaxTimeExpiredError) {
638 throw new MongoOperationTimeoutError('Server reported a timeout error', {
639 cause: new MongoServerError(document.toObject())
640 });
641 }
642 } else {
643 if (
644 (Array.isArray(document?.writeErrors) &&
645 document.writeErrors.some(
646 error => error?.code === MONGODB_ERROR_CODES.MaxTimeMSExpired
647 )) ||
648 document?.writeConcernError?.code === MONGODB_ERROR_CODES.MaxTimeMSExpired
649 ) {
650 throw new MongoOperationTimeoutError('Server reported a timeout error', {
651 cause: new MongoServerError(document)
652 });
653 }
654 }
655 }
656
657 return document;
658 }
659 throw new MongoUnexpectedServerResponseError('Unable to get response from server');
660 }
661
662 public exhaustCommand(
663 ns: MongoDBNamespace,

Callers 11

executeHandshakeFunction · 0.45
commandMethod · 0.45
authMethod · 0.45
externalCommandFunction · 0.45
authMethod · 0.45
authMethod · 0.45
executeScramFunction · 0.45
startAuthenticationFunction · 0.45
finishAuthenticationFunction · 0.45
markCommandMethod · 0.45

Calls 5

throwIfAbortedMethod · 0.95
sendCommandMethod · 0.95
csotEnabledMethod · 0.45
isMethod · 0.45
toObjectMethod · 0.45

Tested by

no test coverage detected