Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MongoClient

A Vert.x service used to interact with MongoDB server instances.

Some of the operations might change _id field of passed document.

Hierarchy

  • MongoClient

Index

Properties

Static Readonly DEFAULT_DB_NAME

DEFAULT_DB_NAME: string

The name of the default database

Static Readonly DEFAULT_POOL_NAME

DEFAULT_POOL_NAME: string

The name of the default pool

Methods

aggregate

  • aggregate(collection: string, pipeline: any[]): ReadStream<{}>
  • Run aggregate MongoDB command with default AggregateOptions.

    Parameters

    • collection: string
    • pipeline: any[]

    Returns ReadStream<{}>

aggregateWithOptions

  • aggregateWithOptions(collection: string, pipeline: any[], options: AggregateOptions): ReadStream<{}>
  • Run aggregate MongoDB command.

    Parameters

    Returns ReadStream<{}>

bulkWrite

  • Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.

    Parameters

    Returns PromiseLike<MongoClientBulkWriteResult>

  • Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.

    Parameters

    Returns MongoClient

bulkWriteWithOptions

  • Execute a bulk operation with the specified write options. Can insert, update, replace, and/or delete multiple documents with one request.

    Parameters

    Returns PromiseLike<MongoClientBulkWriteResult>

  • Execute a bulk operation with the specified write options. Can insert, update, replace, and/or delete multiple documents with one request.

    Parameters

    Returns MongoClient

close

  • close(): PromiseLike<void>
  • close(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Close the client and release its resources

    Returns PromiseLike<void>

  • Close the client and release its resources

    Parameters

    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

count

  • count(collection: string, query: {}): PromiseLike<number>
  • count(collection: string, query: {}, resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): MongoClient
  • Count matching documents in a collection.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<number>

  • Count matching documents in a collection.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>

    Returns MongoClient

countWithOptions

  • countWithOptions(collection: string, query: {}, countOptions: CountOptions): PromiseLike<number>
  • countWithOptions(collection: string, query: {}, countOptions: CountOptions, resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): MongoClient
  • Count matching documents in a collection.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • countOptions: CountOptions

    Returns PromiseLike<number>

  • Count matching documents in a collection.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • countOptions: CountOptions
    • resultHandler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>

    Returns MongoClient

createCollection

  • createCollection(collectionName: string): PromiseLike<void>
  • createCollection(collectionName: string, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Create a new collection

    Parameters

    • collectionName: string

    Returns PromiseLike<void>

  • Create a new collection

    Parameters

    • collectionName: string
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

createCollectionWithOptions

  • createCollectionWithOptions(collectionName: string, collectionOptions: CreateCollectionOptions): PromiseLike<void>
  • createCollectionWithOptions(collectionName: string, collectionOptions: CreateCollectionOptions, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Create a new collection with options

    Parameters

    Returns PromiseLike<void>

  • Create a new collection with options

    Parameters

    • collectionName: string
    • collectionOptions: CreateCollectionOptions
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

createDefaultGridFsBucketService

createGridFsBucketService

  • Creates a MongoGridFsClient used to interact with Mongo GridFS.

    Parameters

    • bucketName: string

    Returns PromiseLike<MongoGridFsClient>

  • Creates a MongoGridFsClient used to interact with Mongo GridFS.

    Parameters

    Returns MongoClient

createIndex

  • createIndex(collection: string, key: {}): PromiseLike<void>
  • createIndex(collection: string, key: {}, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Creates an index.

    Parameters

    • collection: string
    • key: {}
      • [key: string]: any

    Returns PromiseLike<void>

  • Creates an index.

    Parameters

    • collection: string
    • key: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

createIndexWithOptions

  • createIndexWithOptions(collection: string, key: {}, options: IndexOptions): PromiseLike<void>
  • createIndexWithOptions(collection: string, key: {}, options: IndexOptions, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Creates an index.

    Parameters

    • collection: string
    • key: {}
      • [key: string]: any
    • options: IndexOptions

    Returns PromiseLike<void>

  • Creates an index.

    Parameters

    • collection: string
    • key: {}
      • [key: string]: any
    • options: IndexOptions
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

createIndexes

  • createIndexes(collection: string, indexes: IndexModel): PromiseLike<void>
  • createIndexes(collection: string, indexes: IndexModel, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • creates an indexes

    Parameters

    Returns PromiseLike<void>

  • creates an indexes

    Parameters

    • collection: string
    • indexes: IndexModel
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

distinct

  • distinct(collection: string, fieldName: string, resultClassname: string): PromiseLike<any[]>
  • distinct(collection: string, fieldName: string, resultClassname: string, resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): MongoClient
  • distinct(collection: string, fieldName: string, resultClassname: string, distinctOptions: DistinctOptions): PromiseLike<any[]>
  • distinct(collection: string, fieldName: string, resultClassname: string, distinctOptions: DistinctOptions, resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): MongoClient
  • Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string

    Returns PromiseLike<any[]>

  • Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns MongoClient

  • Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • distinctOptions: DistinctOptions

    Returns PromiseLike<any[]>

  • Gets the distinct values of the specified field name. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • distinctOptions: DistinctOptions
    • resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns MongoClient

distinctBatch

  • distinctBatch(collection: string, fieldName: string, resultClassname: string): ReadStream<{}>
  • distinctBatch(collection: string, fieldName: string, resultClassname: string, distinctOptions: DistinctOptions): ReadStream<{}>
  • Gets the distinct values of the specified field name. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string

    Returns ReadStream<{}>

  • Gets the distinct values of the specified field name. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • distinctOptions: DistinctOptions

    Returns ReadStream<{}>

distinctBatchWithQuery

  • distinctBatchWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}): ReadStream<{}>
  • distinctBatchWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, distinctOptions: DistinctOptions): ReadStream<{}>
  • distinctBatchWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, batchSize: number): ReadStream<{}>
  • distinctBatchWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, batchSize: number, distinctOptions: DistinctOptions): ReadStream<{}>
  • Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any

    Returns ReadStream<{}>

  • Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • distinctOptions: DistinctOptions

    Returns ReadStream<{}>

  • Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • batchSize: number

    Returns ReadStream<{}>

  • Gets the distinct values of the specified field name filtered by specified query. This method use batchCursor for returning each found value. Each value is a json fragment with fieldName key (eg: {"num": 1}).

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • batchSize: number
    • distinctOptions: DistinctOptions

    Returns ReadStream<{}>

distinctWithQuery

  • distinctWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}): PromiseLike<any[]>
  • distinctWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): MongoClient
  • distinctWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, distinctOptions: DistinctOptions): PromiseLike<any[]>
  • distinctWithQuery(collection: string, fieldName: string, resultClassname: string, query: {}, distinctOptions: DistinctOptions, resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): MongoClient
  • Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<any[]>

  • Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns MongoClient

  • Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • distinctOptions: DistinctOptions

    Returns PromiseLike<any[]>

  • Gets the distinct values of the specified field name filtered by specified query. Return a JsonArray containing distinct values (eg: [ 1 , 89 ])

    Parameters

    • collection: string
    • fieldName: string
    • resultClassname: string
    • query: {}
      • [key: string]: any
    • distinctOptions: DistinctOptions
    • resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns MongoClient

dropCollection

  • dropCollection(collection: string): PromiseLike<void>
  • dropCollection(collection: string, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Drop a collection

    Parameters

    • collection: string

    Returns PromiseLike<void>

  • Drop a collection

    Parameters

    • collection: string
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

dropIndex

  • dropIndex(collection: string, indexName: string): PromiseLike<void>
  • dropIndex(collection: string, indexName: string, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): MongoClient
  • Drops the index given its name.

    Parameters

    • collection: string
    • indexName: string

    Returns PromiseLike<void>

  • Drops the index given its name.

    Parameters

    • collection: string
    • indexName: string
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns MongoClient

find

  • find(collection: string, query: {}): PromiseLike<{}>
  • find(collection: string, query: {}, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find matching documents in the specified collection

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<{}>

  • Find matching documents in the specified collection

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findBatch

  • findBatch(collection: string, query: {}): ReadStream<{}>
  • Find matching documents in the specified collection. This method use batchCursor for returning each found document.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns ReadStream<{}>

findBatchWithOptions

  • findBatchWithOptions(collection: string, query: {}, options: FindOptions): ReadStream<{}>
  • Find matching documents in the specified collection, specifying options. This method use batchCursor for returning each found document.

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • options: FindOptions

    Returns ReadStream<{}>

findOne

  • findOne(collection: string, query: {}, fields: {} | null | undefined): PromiseLike<{}>
  • findOne(collection: string, query: {}, fields: {} | null | undefined, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • fields: {} | null | undefined

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • fields: {} | null | undefined
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndDelete

  • findOneAndDelete(collection: string, query: {}): PromiseLike<{}>
  • findOneAndDelete(collection: string, query: {}, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and delete it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and delete it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndDeleteWithOptions

  • findOneAndDeleteWithOptions(collection: string, query: {}, findOptions: FindOptions): PromiseLike<{}>
  • findOneAndDeleteWithOptions(collection: string, query: {}, findOptions: FindOptions, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and delete it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • findOptions: FindOptions

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and delete it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • findOptions: FindOptions
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndReplace

  • findOneAndReplace(collection: string, query: {}, replace: {}): PromiseLike<{}>
  • findOneAndReplace(collection: string, query: {}, replace: {}, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and replace it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and replace it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndReplaceWithOptions

  • findOneAndReplaceWithOptions(collection: string, query: {}, replace: {}, findOptions: FindOptions, updateOptions: UpdateOptions): PromiseLike<{}>
  • findOneAndReplaceWithOptions(collection: string, query: {}, replace: {}, findOptions: FindOptions, updateOptions: UpdateOptions, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and replace it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any
    • findOptions: FindOptions
    • updateOptions: UpdateOptions

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and replace it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any
    • findOptions: FindOptions
    • updateOptions: UpdateOptions
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndUpdate

  • findOneAndUpdate(collection: string, query: {}, update: {}): PromiseLike<{}>
  • findOneAndUpdate(collection: string, query: {}, update: {}, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and update it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and update it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findOneAndUpdateWithOptions

  • findOneAndUpdateWithOptions(collection: string, query: {}, update: {}, findOptions: FindOptions, updateOptions: UpdateOptions): PromiseLike<{}>
  • findOneAndUpdateWithOptions(collection: string, query: {}, update: {}, findOptions: FindOptions, updateOptions: UpdateOptions, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find a single matching document in the specified collection and update it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any
    • findOptions: FindOptions
    • updateOptions: UpdateOptions

    Returns PromiseLike<{}>

  • Find a single matching document in the specified collection and update it.

    This operation might change _id field of query parameter

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any
    • findOptions: FindOptions
    • updateOptions: UpdateOptions
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

findWithOptions

  • findWithOptions(collection: string, query: {}, options: FindOptions): PromiseLike<{}>
  • findWithOptions(collection: string, query: {}, options: FindOptions, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Find matching documents in the specified collection, specifying options

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • options: FindOptions

    Returns PromiseLike<{}>

  • Find matching documents in the specified collection, specifying options

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • options: FindOptions
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

getCollections

  • getCollections(): PromiseLike<string>
  • getCollections(resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>): MongoClient
  • Get a list of all collections in the database.

    Returns PromiseLike<string>

  • Get a list of all collections in the database.

    Parameters

    • resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>

    Returns MongoClient

insert

  • insert(collection: string, document: {}): PromiseLike<string>
  • insert(collection: string, document: {}, resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>): MongoClient
  • Insert a document in the specified collection

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any

    Returns PromiseLike<string>

  • Insert a document in the specified collection

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>

    Returns MongoClient

insertWithOptions

  • insertWithOptions(collection: string, document: {}, writeOption: WriteOption | null | undefined): PromiseLike<string>
  • insertWithOptions(collection: string, document: {}, writeOption: WriteOption | null | undefined, resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>): MongoClient
  • Insert a document in the specified collection with the specified write option

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined

    Returns PromiseLike<string>

  • Insert a document in the specified collection with the specified write option

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined
    • resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>

    Returns MongoClient

listIndexes

  • listIndexes(collection: string): PromiseLike<any[]>
  • listIndexes(collection: string, resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): MongoClient
  • Get all the indexes in this collection.

    Parameters

    • collection: string

    Returns PromiseLike<any[]>

  • Get all the indexes in this collection.

    Parameters

    • collection: string
    • resultHandler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns MongoClient

removeDocument

  • Remove a single matching document from a collection and return the handler with MongoClientDeleteResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<MongoClientDeleteResult>

  • Remove a single matching document from a collection and return the handler with MongoClientDeleteResult result

    Parameters

    Returns MongoClient

removeDocumentWithOptions

  • Remove a single matching document from a collection with the specified write option and return the handler with MongoClientDeleteResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined

    Returns PromiseLike<MongoClientDeleteResult>

  • Remove a single matching document from a collection with the specified write option and return the handler with MongoClientDeleteResult result

    Parameters

    Returns MongoClient

removeDocuments

  • Remove matching documents from a collection and return the handler with MongoClientDeleteResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any

    Returns PromiseLike<MongoClientDeleteResult>

  • Remove matching documents from a collection and return the handler with MongoClientDeleteResult result

    Parameters

    Returns MongoClient

removeDocumentsWithOptions

  • Remove matching documents from a collection with the specified write option and return the handler with MongoClientDeleteResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined

    Returns PromiseLike<MongoClientDeleteResult>

  • Remove matching documents from a collection with the specified write option and return the handler with MongoClientDeleteResult result

    Parameters

    Returns MongoClient

replaceDocuments

  • Replace matching documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any

    Returns PromiseLike<MongoClientUpdateResult>

  • Replace matching documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

replaceDocumentsWithOptions

  • Replace matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • replace: {}
      • [key: string]: any
    • options: UpdateOptions

    Returns PromiseLike<MongoClientUpdateResult>

  • Replace matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

runCommand

  • runCommand(commandName: string, command: {}): PromiseLike<{}>
  • runCommand(commandName: string, command: {}, resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>): MongoClient
  • Run an arbitrary MongoDB command.

    Parameters

    • commandName: string
    • command: {}
      • [key: string]: any

    Returns PromiseLike<{}>

  • Run an arbitrary MongoDB command.

    Parameters

    • commandName: string
    • command: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<{}>) => void) | Handler<AsyncResult<{}>>

    Returns MongoClient

save

  • save(collection: string, document: {}): PromiseLike<string>
  • save(collection: string, document: {}, resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>): MongoClient
  • Save a document in the specified collection

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any

    Returns PromiseLike<string>

  • Save a document in the specified collection

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>

    Returns MongoClient

saveWithOptions

  • saveWithOptions(collection: string, document: {}, writeOption: WriteOption | null | undefined): PromiseLike<string>
  • saveWithOptions(collection: string, document: {}, writeOption: WriteOption | null | undefined, resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>): MongoClient
  • Save a document in the specified collection with the specified write option

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined

    Returns PromiseLike<string>

  • Save a document in the specified collection with the specified write option

    This operation might change _id field of document parameter

    Parameters

    • collection: string
    • document: {}
      • [key: string]: any
    • writeOption: WriteOption | null | undefined
    • resultHandler: ((res: AsyncResult<string>) => void) | Handler<AsyncResult<string>>

    Returns MongoClient

updateCollection

  • Update matching documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any

    Returns PromiseLike<MongoClientUpdateResult>

  • Update matching documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

  • Use an aggregation pipeline to update documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: any[]

    Returns PromiseLike<MongoClientUpdateResult>

  • Use an aggregation pipeline to update documents in the specified collection and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

updateCollectionWithOptions

  • Update matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: {}
      • [key: string]: any
    • options: UpdateOptions

    Returns PromiseLike<MongoClientUpdateResult>

  • Update matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

  • Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    • collection: string
    • query: {}
      • [key: string]: any
    • update: any[]
    • options: UpdateOptions

    Returns PromiseLike<MongoClientUpdateResult>

  • Use an aggregation pipeline to update documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result

    Parameters

    Returns MongoClient

watch

  • watch(collection: string, pipeline: any[], withUpdatedDoc: boolean, batchSize: number): ReadStream<any>
  • Watch the collection change.

    Parameters

    • collection: string
    • pipeline: any[]
    • withUpdatedDoc: boolean
    • batchSize: number

    Returns ReadStream<any>

Static create

  • Create a Mongo client which maintains its own data source.

    Parameters

    • vertx: Vertx
    • config: {}
      • [key: string]: any

    Returns MongoClient

Static createShared

  • createShared(vertx: Vertx, config: {}, dataSourceName: string): MongoClient
  • createShared(vertx: Vertx, config: {}): MongoClient
  • Create a Mongo client which shares its data source with any other Mongo clients created with the same data source name

    Parameters

    • vertx: Vertx
    • config: {}
      • [key: string]: any
    • dataSourceName: string

    Returns MongoClient

  • Like {@link MongoClient#createShared} but with the default data source name

    Parameters

    • vertx: Vertx
    • config: {}
      • [key: string]: any

    Returns MongoClient

Generated using TypeDoc