@@ -21,7 +21,7 @@ import {
2121} from '../error' ;
2222import type { ServerApi , SupportedNodeConnectionOptions } from '../mongo_client' ;
2323import { CancellationToken , TypedEventEmitter } from '../mongo_types' ;
24- import { ReadPreference , ReadPreferenceLike } from '../read_preference' ;
24+ import type { ReadPreference , ReadPreferenceLike } from '../read_preference' ;
2525import { applySession , ClientSession , updateSessionFromResponse } from '../sessions' ;
2626import {
2727 calculateDurationInMs ,
@@ -45,7 +45,6 @@ import {
4545 GetMore ,
4646 KillCursor ,
4747 Msg ,
48- OpQueryOptions ,
4948 Query ,
5049 Response ,
5150 WriteProtocolMessageType
@@ -565,78 +564,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
565564 }
566565 }
567566
568- query ( ns : MongoDBNamespace , cmd : Document , options : QueryOptions , callback : Callback ) : void {
569- const isExplain = cmd . $explain != null ;
570- const readPreference = options . readPreference ?? ReadPreference . primary ;
571- const batchSize = options . batchSize || 0 ;
572- const limit = options . limit ;
573- const numberToSkip = options . skip || 0 ;
574- let numberToReturn = 0 ;
575- if (
576- limit &&
577- ( limit < 0 || ( limit !== 0 && limit < batchSize ) || ( limit > 0 && batchSize === 0 ) )
578- ) {
579- numberToReturn = limit ;
580- } else {
581- numberToReturn = batchSize ;
582- }
583-
584- if ( isExplain ) {
585- // nToReturn must be 0 (match all) or negative (match N and close cursor)
586- // nToReturn > 0 will give explain results equivalent to limit(0)
587- numberToReturn = - Math . abs ( limit || 0 ) ;
588- }
589-
590- const queryOptions : OpQueryOptions = {
591- numberToSkip,
592- numberToReturn,
593- pre32Limit : typeof limit === 'number' ? limit : undefined ,
594- checkKeys : false ,
595- secondaryOk : readPreference . secondaryOk ( )
596- } ;
597-
598- if ( options . projection ) {
599- queryOptions . returnFieldSelector = options . projection ;
600- }
601-
602- const query = new Query ( ns . toString ( ) , cmd , queryOptions ) ;
603- if ( typeof options . tailable === 'boolean' ) {
604- query . tailable = options . tailable ;
605- }
606-
607- if ( typeof options . oplogReplay === 'boolean' ) {
608- query . oplogReplay = options . oplogReplay ;
609- }
610-
611- if ( typeof options . timeout === 'boolean' ) {
612- query . noCursorTimeout = ! options . timeout ;
613- } else if ( typeof options . noCursorTimeout === 'boolean' ) {
614- query . noCursorTimeout = options . noCursorTimeout ;
615- }
616-
617- if ( typeof options . awaitData === 'boolean' ) {
618- query . awaitData = options . awaitData ;
619- }
620-
621- if ( typeof options . partial === 'boolean' ) {
622- query . partial = options . partial ;
623- }
624-
625- write (
626- this ,
627- query ,
628- { [ kFullResult ] : true , ...pluckBSONSerializeOptions ( options ) } ,
629- ( err , result ) => {
630- if ( err || ! result ) return callback ( err , result ) ;
631- if ( isExplain && result . documents && result . documents [ 0 ] ) {
632- return callback ( undefined , result . documents [ 0 ] ) ;
633- }
634-
635- callback ( undefined , result ) ;
636- }
637- ) ;
638- }
639-
640567 getMore (
641568 ns : MongoDBNamespace ,
642569 cursorId : Long ,
0 commit comments