import * as mongodb from "mongodb" ; import { MockCursor } from "./mockCursor" ; import { MockBulk } from "./mockBulk" ; import { MongoCallback } from "mongodb" ; import { AggregationCursor } from "mongodb" ; import { CollectionAggregationOptions } from "mongodb" ; import { MongoCountPreferences } from "mongodb" ; import { BulkWriteOpResultObject } from "mongodb" ; import { CollectionBulkWriteOptions } from "mongodb" ; export class MockCollection < TSchema = any > implements mongodb . Collection { collectionName : string ; namespace : string ; writeConcern : any ; readConcern : any ; hint : any ; bulk : MockBulk ; constructor ( public contents ? , name ? ) { this . collectionName = name ; } aggregate < T = TSchema > ( callback ) ; aggregate < T = TSchema > ( pipeline , callback ) ; aggregate < T = TSchema > ( pipeline ? , options ? , callback ? ) ; aggregate ( pipeline , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } bulkWrite ( operations , callback ) ; bulkWrite ( operations , options ? ) ; bulkWrite ( operations , options , callback ) ; bulkWrite ( operations , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } count ( query , callback ) ; count ( query , options ? ) ; count ( query , options , callback ) ; count ( query , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } countDocuments ( callback ) ; countDocuments ( query , callback ) ; countDocuments ( query ? , options ? ) ; countDocuments ( query , options , callback ) ; countDocuments ( query , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } createIndex ( fieldOrSpec , callback ) ; createIndex ( fieldOrSpec , options ? ) ; createIndex ( fieldOrSpec , options , callback ) ; createIndex ( fieldOrSpec , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } createIndexes ( indexSpecs , callback ) ; createIndexes ( indexSpecs , options ? ) ; createIndexes ( indexSpecs , options , callback ) ; createIndexes ( indexSpecs , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } deleteMany ( filter , callback ) ; deleteMany ( filter , options ? ) ; deleteMany ( filter , options , callback ) ; deleteMany ( filter , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } deleteOne ( filter , callback ) ; deleteOne ( filter , options ? ) ; deleteOne ( filter , options , callback ) ; deleteOne ( filter , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } distinct ( key , query , callback ) ; distinct ( key , query , options ? ) ; distinct ( key , query , options , callback ) ; distinct ( key , query , options ? , callback ? ) { if ( this . onDistinct ) { process . nextTick ( ( ) => this . onDistinct ( key , query , options , callback ) ) ; return ; } } onDistinct : ( key : string , query : Object , options : any , callback : ( err : Error , result : any ) => void ) => void ; drop ( options ? ) ; drop ( callback ) ; drop ( options , callback ) ; drop ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } dropIndex ( indexName , callback ) ; dropIndex ( indexName , options ? ) ; dropIndex ( indexName , options , callback ) ; dropIndex ( indexName , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } dropIndexes ( options ? ) ; dropIndexes ( callback ? ) ; dropIndexes ( options , callback ) ; dropIndexes ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } find < T = any > ( query ? ) ; find < T = any > ( query , options ? ) ; find ( query ? , options ? ) { if ( this . onFind ) { return this . onFind ( query , options ) ; } return this . createCursor ( ) ; } createCursor ( ) { return new MockCursor ( this . contents ) ; } onFind : ( selector : Object , options : mongodb . FindOneOptions ) => mongodb . Cursor ; findOne < T = any > ( filter , callback ) ; findOne < T = any > ( filter , options ? ) ; findOne < T = any > ( filter , options , callback ) ; findOne ( filter , optionsOrCallback ? , callback ? ) { var options ; if ( typeof optionsOrCallback === "function" ) { callback = optionsOrCallback ; } else { options = optionsOrCallback ; } if ( this . onFindOne ) { process . nextTick ( ( ) => this . onFindOne ( filter , options , callback ) ) ; return ; } process . nextTick ( ( ) => { callback ( null , this . contents [ 0 ] ) ; } ) ; } onFindOne : ( selector : Object , options : mongodb . FindOneOptions , callback ? : ( err : Error , result : any ) => void ) => any ; findOneAndDelete ( filter , callback ) ; findOneAndDelete ( filter , options ? ) ; findOneAndDelete ( filter , options , callback ) ; findOneAndDelete ( filter , optionsOrCallback ? , callback ? ) { if ( typeof optionsOrCallback === "function" ) { callback = optionsOrCallback ; optionsOrCallback = { } ; } process . nextTick ( ( ) => this . onFindOneAndDelete ( filter , optionsOrCallback , callback ) ) ; } onFindOneAndDelete : ( filter : any , options : any , callback : any ) => void ; findOneAndReplace ( filter , replacement , callback ) ; findOneAndReplace ( filter , replacement , options ? ) ; findOneAndReplace ( filter , replacement , options , callback ) ; findOneAndReplace ( filter , replacement , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } findOneAndUpdate ( filter , update , callback ) ; findOneAndUpdate ( filter , update , options ? ) ; findOneAndUpdate ( filter , update , options , callback ) ; findOneAndUpdate ( filter , update , optionsOrCallback ? , callback ? ) { if ( typeof optionsOrCallback === "function" ) { callback = optionsOrCallback ; optionsOrCallback = { } ; } process . nextTick ( ( ) => this . onFindOneAndUpdate ( filter , update , optionsOrCallback , callback ) ) ; } onFindOneAndUpdate : ( filter : any , update : any , options : any , callback : any ) => void ; geoHaystackSearch ( x , y , callback ) ; geoHaystackSearch ( x , y , options ? ) ; geoHaystackSearch ( x , y , options , callback ) ; geoHaystackSearch ( x , y , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } geoNear ( x , y , callback ) ; geoNear ( x , y , options ? ) ; geoNear ( x , y , options , callback ) ; geoNear ( x , y , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } group ( keys , condition , initial , reduce , finalize , command , callback ) ; group ( keys , condition , initial , reduce , finalize , command , options ? ) ; group ( keys , condition , initial , reduce , finalize , command , options , callback ) ; group ( keys , condition , initial , reduce , finalize , command , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } indexes ( options ? ) ; indexes ( callback ) ; indexes ( options , callback ) ; indexes ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } indexExists ( indexes , callback ) ; indexExists ( indexes , options ? ) ; indexExists ( indexes , options , callback ) ; indexExists ( indexes , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } indexInformation ( callback ) ; indexInformation ( options ? ) ; indexInformation ( options , callback ) ; indexInformation ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } initializeOrderedBulkOp ( options ? ) { throw new Error ( "Method not implemented." ) ; } initializeUnorderedBulkOp ( options ? ) { return this . bulk = new MockBulk ( ) ; } insert ( docs , callback ) ; insert ( docs , options ? ) ; insert ( docs , options , callback ) ; insert ( docs , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } insertMany ( docs , callback ) ; insertMany ( docs , options ? ) ; insertMany ( docs , options , callback ) ; insertMany ( docs , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } insertOne ( docs , callback ) ; insertOne ( docs , options ? ) ; insertOne ( docs , options , callback ) ; insertOne ( docs , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } isCapped ( options ? ) ; isCapped ( callback ) ; isCapped ( options , callback ) ; isCapped ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } listIndexes ( options ? ) { throw new Error ( "Method not implemented." ) ; } mapReduce ( map , reduce , callback ) ; mapReduce ( map , reduce , options ? ) ; mapReduce ( map , reduce , options , callback ) ; mapReduce ( map , reduce , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } options ( options ? ) ; options ( callback ) ; options ( options , callback ) ; options ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } parallelCollectionScan ( callback ) ; parallelCollectionScan ( options ? ) ; parallelCollectionScan ( options , callback ) ; parallelCollectionScan ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } reIndex ( options ? ) ; reIndex ( callback ) ; reIndex ( options , callback ) ; reIndex ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } remove ( selector , callback ) ; remove ( selector , options ? ) ; remove ( selector , options ? , callback ? ) ; remove ( selector , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } rename ( newName , callback ) ; rename ( newName , options ? ) ; rename ( newName , options , callback ) ; rename ( newName , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } replaceOne ( filter , doc , callback ) ; replaceOne ( filter , doc , options ? ) ; replaceOne ( filter , doc , options , callback ) ; replaceOne ( filter , doc , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } save ( doc , callback ) ; save ( doc , options ? ) ; save ( doc , options , callback ) ; save ( doc , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } stats ( callback ) ; stats ( options ? ) ; stats ( options , callback ) ; stats ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } update ( filter , update , callback ) ; update ( filter , update , options ? ) ; update ( filter , update , options , callback ) ; update ( filter , update , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } updateMany ( filter , update , callback ) ; updateMany ( filter , update , options ? ) ; updateMany ( filter , update , options , callback ) ; updateMany ( filter , update , options ? , callback ? ) { if ( this . onUpdateMany ) { process . nextTick ( ( ) => this . onUpdateMany ( filter , update , options , callback ) ) ; return ; } } onUpdateMany : ( filter : Object , update : any , options : any , callback : ( err : Error , result : any ) => void ) => void ; updateOne ( filter , update , callback ) ; updateOne ( filter , update , options ? ) ; updateOne ( filter , update , options , callback ) ; updateOne ( filter , update , options ? , callback ? ) { if ( this . onUpdateOne ) { process . nextTick ( ( ) => this . onUpdateOne ( filter , update , options , callback ) ) ; return ; } } onUpdateOne : ( filter : Object , update : any , options : any , callback : ( err : Error , result : any ) => void ) => void ; watch ( pipeline ? , options ? ) { throw new Error ( "Method not implemented." ) ; } estimatedDocumentCount ( callback ) ; estimatedDocumentCount ( query , callback ) ; estimatedDocumentCount ( query ? , options ? ) ; estimatedDocumentCount ( query , options , callback ) ; estimatedDocumentCount ( query ? , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } }