@@ -96,6 +96,7 @@ import { HIDDEN_COMMANDS } from '@mongosh/history';
9696import PlanCache from './plan-cache' ;
9797import ChangeStreamCursor from './change-stream-cursor' ;
9898import { ShellApiErrors } from './error-codes' ;
99+ import type { MQLQuery , MQLPipeline } from './mql-types' ;
99100
100101export type CollectionWithSchema <
101102 M extends GenericServerSideSchema = GenericServerSideSchema ,
@@ -188,20 +189,20 @@ export class Collection<
188189 * @returns {Promise } The promise of aggregation results.
189190 */
190191 async aggregate (
191- pipeline : Document [ ] ,
192+ pipeline : MQLPipeline ,
192193 options : AggregateOptions & { explain : ExplainVerbosityLike }
193194 ) : Promise < Document > ;
194195 async aggregate (
195- pipeline : Document [ ] ,
196+ pipeline : MQLPipeline ,
196197 options ?: AggregateOptions
197198 ) : Promise < AggregationCursor > ;
198- async aggregate ( ...stages : Document [ ] ) : Promise < AggregationCursor > ;
199+ async aggregate ( ...stages : MQLPipeline ) : Promise < AggregationCursor > ;
199200 @returnsPromise
200201 @returnType ( 'AggregationCursor' )
201202 @apiVersions ( [ 1 ] )
202203 async aggregate ( ...args : unknown [ ] ) : Promise < AggregationCursor | Document > {
203204 let options : AggregateOptions ;
204- let pipeline : Document [ ] ;
205+ let pipeline : MQLPipeline ;
205206 if ( args . length === 0 || Array . isArray ( args [ 0 ] ) ) {
206207 options = args [ 1 ] || { } ;
207208 pipeline = ( args [ 0 ] as Document [ ] ) || [ ] ;
@@ -320,7 +321,7 @@ export class Collection<
320321 @serverVersions ( [ '4.0.3' , ServerVersions . latest ] )
321322 @apiVersions ( [ 1 ] )
322323 async countDocuments (
323- query ?: Document ,
324+ query ?: MQLQuery ,
324325 options : CountDocumentsOptions = { }
325326 ) : Promise < number > {
326327 this . _emitCollectionApiCall ( 'countDocuments' , { query, options } ) ;
@@ -413,17 +414,17 @@ export class Collection<
413414 * @returns {Array } The promise of the result.
414415 */
415416 async distinct ( field : string ) : Promise < Document > ;
416- async distinct ( field : string , query : Document ) : Promise < Document > ;
417+ async distinct ( field : string , query : MQLQuery ) : Promise < Document > ;
417418 async distinct (
418419 field : string ,
419- query : Document ,
420+ query : MQLQuery ,
420421 options : DistinctOptions
421422 ) : Promise < Document > ;
422423 @returnsPromise
423424 @apiVersions ( [ ] )
424425 async distinct (
425426 field : string ,
426- query ?: Document ,
427+ query ?: MQLQuery ,
427428 options : DistinctOptions = { }
428429 ) : Promise < Document > {
429430 this . _emitCollectionApiCall ( 'distinct' , { field, query, options } ) ;
@@ -476,7 +477,7 @@ export class Collection<
476477 @apiVersions ( [ 1 ] )
477478 @returnsPromise
478479 async find (
479- query ?: Document ,
480+ query ?: MQLQuery ,
480481 projection ?: Document ,
481482 options : FindOptions = { }
482483 ) : Promise < Cursor > {
@@ -560,7 +561,7 @@ export class Collection<
560561 @returnType ( 'Document' )
561562 @apiVersions ( [ 1 ] )
562563 async findOne (
563- query : Document = { } ,
564+ query : MQLQuery = { } ,
564565 projection ?: Document ,
565566 options : FindOptions = { }
566567 ) : Promise < C [ 'schema' ] | null > {
@@ -893,7 +894,7 @@ export class Collection<
893894 @serverVersions ( [ ServerVersions . earliest , '3.2.0' ] )
894895 @apiVersions ( [ 1 ] )
895896 async remove (
896- query : Document ,
897+ query : MQLQuery ,
897898 options : boolean | RemoveShellOptions = { }
898899 ) : Promise < DeleteResult | Document > {
899900 await this . _instanceState . printDeprecationWarning (
@@ -2332,7 +2333,7 @@ export class Collection<
23322333 @apiVersions ( [ 1 ] )
23332334 @returnsPromise
23342335 async watch (
2335- pipeline : Document [ ] | ChangeStreamOptions = [ ] ,
2336+ pipeline : MQLPipeline | ChangeStreamOptions = [ ] ,
23362337 options : ChangeStreamOptions = { }
23372338 ) : Promise < ChangeStreamCursor > {
23382339 if ( ! Array . isArray ( pipeline ) ) {
0 commit comments