@@ -416,7 +416,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
416
416
private async * sendWire (
417
417
message : WriteProtocolMessageType ,
418
418
options : CommandOptions ,
419
- returnAs ?: typeof MongoDBResponse
419
+ responseType ?: typeof MongoDBResponse
420
420
) : AsyncGenerator < MongoDBResponse > {
421
421
this . throwIfAborted ( ) ;
422
422
@@ -443,7 +443,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
443
443
this . socket . setTimeout ( 0 ) ;
444
444
const bson = response . parse ( ) ;
445
445
446
- const document = new ( returnAs ?? MongoDBResponse ) ( bson , 0 , false ) ;
446
+ const document = new ( responseType ?? MongoDBResponse ) ( bson , 0 , false ) ;
447
447
448
448
yield document ;
449
449
this . throwIfAborted ( ) ;
@@ -463,7 +463,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
463
463
ns : MongoDBNamespace ,
464
464
command : Document ,
465
465
options : CommandOptions = { } ,
466
- returnAs ?: typeof MongoDBResponse
466
+ responseType ?: typeof MongoDBResponse
467
467
) {
468
468
const message = this . prepareCommand ( ns . db , command , options ) ;
469
469
@@ -482,7 +482,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
482
482
let document ;
483
483
try {
484
484
this . throwIfAborted ( ) ;
485
- for await ( document of this . sendWire ( message , options , returnAs ) ) {
485
+ for await ( document of this . sendWire ( message , options , responseType ) ) {
486
486
if ( options . session != null ) {
487
487
updateSessionFromResponse ( options . session , document ) ;
488
488
}
@@ -520,7 +520,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
520
520
) ;
521
521
}
522
522
523
- if ( returnAs == null ) {
523
+ if ( responseType == null ) {
524
524
// If `documentsReturnedIn` not set or raw is not enabled, use input bson options
525
525
// Otherwise, support raw flag. Raw only works for cursors that hardcode firstBatch/nextBatch fields
526
526
const bsonOptions =
@@ -578,7 +578,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
578
578
ns : MongoDBNamespace ,
579
579
command : Document ,
580
580
options : CommandOptions | undefined ,
581
- returnAs : T | undefined
581
+ responseType : T | undefined
582
582
) : Promise < T extends undefined ? Document : InstanceType < T > > ;
583
583
584
584
public async command (
@@ -599,10 +599,10 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
599
599
ns : MongoDBNamespace ,
600
600
command : Document ,
601
601
options : CommandOptions = { } ,
602
- returnAs ?: typeof MongoDBResponse
602
+ responseType ?: typeof MongoDBResponse
603
603
) : Promise < Document > {
604
604
this . throwIfAborted ( ) ;
605
- for await ( const document of this . sendCommand ( ns , command , options , returnAs ) ) {
605
+ for await ( const document of this . sendCommand ( ns , command , options , responseType ) ) {
606
606
return document ;
607
607
}
608
608
throw new MongoUnexpectedServerResponseError ( 'Unable to get response from server' ) ;
@@ -732,7 +732,7 @@ export class CryptoConnection extends Connection {
732
732
ns : MongoDBNamespace ,
733
733
command : Document ,
734
734
options : CommandOptions | undefined ,
735
- returnAs : T
735
+ responseType : T
736
736
) : Promise < InstanceType < T > > ;
737
737
738
738
public override async command (
@@ -747,7 +747,7 @@ export class CryptoConnection extends Connection {
747
747
ns : MongoDBNamespace ,
748
748
cmd : Document ,
749
749
options ?: CommandOptions ,
750
- returnAs ?: T | undefined
750
+ responseType ?: T | undefined
751
751
) : Promise < Document > {
752
752
const { autoEncrypter } = this ;
753
753
if ( ! autoEncrypter ) {
@@ -757,7 +757,7 @@ export class CryptoConnection extends Connection {
757
757
const serverWireVersion = maxWireVersion ( this ) ;
758
758
if ( serverWireVersion === 0 ) {
759
759
// This means the initial handshake hasn't happened yet
760
- return await super . command < T > ( ns , cmd , options , returnAs ) ;
760
+ return await super . command < T > ( ns , cmd , options , responseType ) ;
761
761
}
762
762
763
763
if ( serverWireVersion < 8 ) {
@@ -791,7 +791,7 @@ export class CryptoConnection extends Connection {
791
791
}
792
792
}
793
793
794
- const response = await super . command < T > ( ns , encrypted , options , returnAs ) ;
794
+ const response = await super . command < T > ( ns , encrypted , options , responseType ) ;
795
795
796
796
return await autoEncrypter . decrypt ( response , options ) ;
797
797
}
0 commit comments